|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can somebody please help me with this problem ?
I have many URLs registered, but all pointing at the same address WWW.MYNAME.COM Is it possible to write a JS to be placed in the head wich does the following: check what is written in the URL box and redirect to a subfolder! ie: If URL=MYNAME.COM then stay on page If URL=ALFA.NET then goto MYNAME.COM/ALFA If URL=BRAVO.COM then goto MYNAME.COM/BRAVO .. and so on Sorry for this BASIC look of the code ! I think it can be done using History(0) (or maybe -1, it depends I think). It shoulkd be in the very first lines of the page, so to redirect away asap. Thankyou very much for any help you can give me ! Bye |
|
#2
|
|||
|
|||
|
<SCRIPT LANGUAGE="JavaScript">
<!-- if (top.location.href.search('[Aa][Ll][Ff][Aa]') > -1) { top.location.href = 'http://www.myname.com/alfa/'; } if (top.location.href.search('[Bb][Rr][Aa][Vv][Oo]') > -1) { top.location.href = 'http://www.myname.com/bravo/'; } //--> </SCRIPT> It has to be done this way because the .indexOf() function is case sensitive, and you can't do .toLowerCase.indexOf()... the above uses something called regular expressions so it is case insensitive. To add another url, you would just surround each letter of the word in the domain name with [ and ] then include both the upper and lowercase letter. |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Redirecting to subfolders on URL basis |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|