Tasmanian Devil
06-02-2003, 08:48 AM
is there any way when a link is clicked depending on the type of browser that it will go to a different page? thanks
|
Click to See Complete Forum and Search --> : Help with IE, Netscape and others Tasmanian Devil 06-02-2003, 08:48 AM is there any way when a link is clicked depending on the type of browser that it will go to a different page? thanks Khalid Ali 06-02-2003, 08:56 AM Yes...you'd need to do something like this. if(document.all){ }else{//NS ??? } Tasmanian Devil 06-02-2003, 09:08 AM Khalid Ali~ I am a newbie so can you show me an example how it would look? Khalid Ali 06-02-2003, 09:24 AM I think the best you can do in this scenarios is to have links in an array <script type="text/javascript"> var linksArr = new Array("http://netscape.net","http://w3c.org","http://microsoft.com","http://msnbc.com"); functionloadURL(index){ if(document.all){ window.location.href = linksArr[index]; }else{//ns ??? window.location.href = linksArr[index]; } } </script> html part of it may look like this <body> <a href="#" onclick="loadURL(0)">Netscape</a><br/> <a href="#" onclick="loadURL(2)">Microsoft</a> I guess you get the idea... :D Charles 06-02-2003, 09:45 AM Originally posted by Tasmanian Devil is there any way when a link is clicked depending on the type of browser that it will go to a different page? thanks That's going to depend upon what you mean by "type of browser". <a href="http://www.defaultPage.com/" onclick="this.url = {Microsoft: 'http://www.microsoftPage.com', Netscape: 'http://www.netscapeVersion.com', Opera: 'http://www.OperaVersion.com'}[navigator.appName]; if (this.url) this.href = this.url">Some Link</a> That example will change the link address according to the name of the bowser. See http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/nav.html for other possibilities. But note: 1) There are hundreds of different types of browsers out there, so you need to specify a default address in the "href" attribute. 2) A good 13% of users do not use JavaScript so you, so you need to specify a default address in the "href" attribute. Tasmanian Devil 06-02-2003, 09:48 AM Khalid Ali~ Thanks for your help Tasmanian Devil 06-02-2003, 09:55 AM Khalid Ali~ Thanks for your help Khalid Ali 06-02-2003, 10:18 AM You are welcome...Devil :D webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |