Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional link

Status
Not open for further replies.

Davide77

Technical User
Mar 6, 2003
166
CH
hallo,
I have a problem with browser compatibility. I know how to make work things for Explorer or for Netscape, but they won't work togeter. The solution is to prepare two different pages and if the user has a Netscape will see the Netscape page and viceversa. The problem is the script that recognize the browser.
I tried with a redirect script: if I click a link I won't go directly to the linked page but to a page with a script that recognize the browser and then choose the right page out of the two (Netscape / explorer). But this script has a problem: when I am, for example in the Netscape-designed page and I click the "back" button of the browser it won't go the previous page because it goes to the script page that will send it back to the Netscape-designed page....

So... another solution could be a conditional link on the first page that says: if the browser is this go to this page, else go to this one...

Does someone have suggestions?

Thankyou
Davide
 
My suggestion would be to do the browser test server-side and then serve different content to the page requested based on the browser (rather than relying on javascript scripts every time).

This will ensure that all browser back button activity is standard, and that users with javascript disabled can still navigate your site (which will assist if it's being crawled by a search engine etc too).

I understand that this may not be an option for you.

Jeff
 

Of course another option would be to tell us why you think you need two pages, one for IE and one for NN... It is entirely possible that you can do with just one page and some smart coding.

It seems [to me] like a more obvious thing to do than trying to split the two pages ;o)

Dan
 
bill,
the solution I see, without considering server side script, is a script that says: if the browser is this than take this "html code" otherwise take this other "html code"... I don't know how to express this in javascript... have you seen it somewhere?

thanks
Davide
 

What I meant was that maybe you could tell us more about why you think you need two different versions of script.

What is the root problem that requires you to have different JS for IE and NN?

It's quite possible that we will be able to help you combine the two codes into one, and avoid the link and avoid the link problem altogether.

Dan
 
I agree with Dan, try to combine into one set of code.

However, if all you're interested in is just detecting the browser and using some IF statements for various parts of your code, there's plenty of resources/examples.



FYI: "...if the browser is this, than take this html code otherwise take..." --- should be "then", not "than".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top