Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Url Redirection = Javascript+html, Redirect using scripts!
AlanDS
post Apr 24 2006, 04:52 PM
Post #1


Newbie [Level 3]
***

Group: Members
Posts: 49
Joined: 22-April 06
Member No.: 22,255



In javascript Browser redirection can be done in 3 ways:

1) Alert Redirect:
CODE
<html>
<script>
    alert("This page has been moved to a new location... click OK to be redirected.");
    location = "http://www.your-website.com";
</script>
</html>



2) Confirm and Redirect:
CODE
<html>
<script>
    if(confirm("This page has been moved to a new location... would you like to be redirected"))
    {
  location = "http://www.your-website.com";
    }
    else
    {
  history.back();
    }
</script>
</html>


3) Stealth Redirect:
CODE
<html>
<script>
    location = "http://www.your-website.com";
</script>
</html>
Go to the top of the page
 
+Quote Post
WindAndWater
post Apr 24 2006, 09:35 PM
Post #2


Advanced Member
*******

Group: Members
Posts: 106
Joined: 1-April 06
Member No.: 21,148
myCENT:ZERO



Browser redirection can also be accomplished through the use of META tags in HTML or through a specific clause in your .htaccess file.

html:
CODE
<META HTTP-EQUIV="refresh" CONTENT="5;URL=http://www.google.com">
will change the page to www.google.com after 5 seconds. Remember that meta tags go within your <head></head> tags.

.htaccess:
CODE
Redirect /site.html http://www.othersite.com/index.html


Whenever it's possible, it's best to use an alterative to javascript, as not all users will have it enabled.

This post has been edited by WindAndWater: Apr 24 2006, 09:36 PM
Go to the top of the page
 
+Quote Post
AlanDS
post Apr 25 2006, 04:36 PM
Post #3


Newbie [Level 3]
***

Group: Members
Posts: 49
Joined: 22-April 06
Member No.: 22,255



Will you please elaborate on how .htaccess is to be used.

Thanks
Go to the top of the page
 
+Quote Post
WindAndWater
post Apr 26 2006, 01:05 AM
Post #4


Advanced Member
*******

Group: Members
Posts: 106
Joined: 1-April 06
Member No.: 21,148
myCENT:ZERO



For some strange reason I can't seem to get redirect to work on my trap17 hosting; my guess is that we don't have mod_rewrite enabled. However, RedirectMatch (allows redirection with regEx matching for the pages) seems to work.

CODE
RedirectMatch permanent fromPage.html http://www.domain.com/toPage.html

"permanent" tells the browser that the redirection is permanent, but doesn't really affect much -- you can remove it if you want. The second page shouldn't have to use an absolute path, but for some reason it doesn't work on my trap17 account unless I do. To use it, simply copy the code snippit into a text editor, switch out the dummy names with real ones, and then save it as a plain-text file named ".htaccess". Once you're done, upload the file to whichever directory the file you want to be redirected is from. Alternatively, you can have your .htaccess file a few directories up (say in your root directory) and just specify the file by including the path.

Trap17 already has a .htaccess file for your www/public_html directory, so if you want to stick your redirection code there, just append it to the other file.
Go to the top of the page
 
+Quote Post
AlanDS
post Apr 27 2006, 12:19 PM
Post #5


Newbie [Level 3]
***

Group: Members
Posts: 49
Joined: 22-April 06
Member No.: 22,255



Thanks for elaborating.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. where did you learn html from?(97)
  2. Redirect Code Help(8)
  3. Html Cool Codes?(6)
  4. Html Editor(22)
  5. Do You Know Html?(65)
  6. Html Question Concerning Pre Tag And Code Tag(8)
  7. Creating Link In Html - Help Me With This!(5)
  8. Wanting To Touch Up/learn My Html Again(27)
  9. Having Html Troubles......(1)
  10. Redirect Problem(6)
  11. Help With Html(11)
  12. Create A Xhtml, Css3 Valid Gallery With Javascript ;part 1(0)
  13. Ok Background Help Please(4)
  14. Some More Help With Html(2)
  15. Html Help(6)
  1. Help With Css/html Layout(5)
  2. How To Redirect(5)
  3. Wanna Learn Html From Scratch(5)
  4. Login In Using Html(12)
  5. Html Application Form(6)
  6. Best Way To Protect Html Form Fields(3)
  7. Html Div Help [resolved](1)
  8. Html Ascii Codes - A Complete List(3)
  9. Help Making A Web Adress Bar Using Html/js(9)
  10. Some Questions On Html(10)
  11. Validating Javascript(2)
  12. Html Code Question(2)
  13. W3schools.com Is Down(7)


 



- Lo-Fi Version Time is now: 23rd November 2008 - 09:57 AM