|
|
|
|
![]() ![]() |
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> |
|
|
|
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 |
|
|
|
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 |
|
|
|
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. |
|
|
|
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.
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 23rd November 2008 - 09:57 AM |