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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browser detect then redirect 1

Status
Not open for further replies.

celticking

Technical User
Feb 15, 2001
69
US
I have a database that when searched lists users. When you select a user, the profile page opens in a new window. There's problems with the page in Netscape and AOL, javascript wont work, so i want to have two profile pages. I need the browser the user is using to be detected then sent to the correct profile page.
Can anyone help?

My current code reads...

<a href=&quot;/itc_detail.lasso?user=[field:'username']&quot; target=&quot;_blank&quot;> [field:'username']</a>
Thanks.

 
Easiest browser detection I know of is this -- it will tell you whether the user is using IE or not

if (document.all)
//user is using ie
else
//user is not using ie (could be NS, Opera, etc...)

you can use the location=url to redirect them based on that test.

:)
Paul Prewett
penny.gif
penny.gif
 
I can i use location-url? Currently i'm using href because the results generated by the database needs to be a link?
Thanks
 
Basically i need the following help...
I have the following link generated from a Db search...
<a href=&quot;/itc_detail.lasso?user=[field:'username']&quot; target=&quot;_blank&quot;>
[field:'username']</a>

It points to /itc_detail.lasso though unfortunately i can't get the javascript on this page to work with Netscape. Is there a way to when the user clicks this link, check the browser and if Netscape redirect to itc_detail2.lasso?

That's unless someone would kindly look at my javascript code to see why it won't work in Netscape or AOL. It's fine in IE. You can see here...

Thanks for any help.
 
Please someone. If i use
<script>
function redirect() {
if (navigator.appName.indexOf(&quot;Netscape&quot;) >=0) location.href=&quot;itc_detail2.lasso?user=[field:'username']&quot;;
}
</script>

How can i get it to work for...

<a href=&quot;/itc_detail.lasso?user=[field:'username']&quot; target=&quot;_blank&quot;> To work on clicking the hyperlink.
I'm really desperate to get this working,
Thanks.
 
<a href=&quot;javascript:redirect();&quot;>Click here</a>

Is that what you mean???
penny.gif
penny.gif
 
I'm not sure how that'll work. All i want is from the hyperlink.... <a href=&quot;/itc_detail.lasso?user=[field:'username']&quot; target=&quot;_blank&quot;>

To go to one of two pages depeneding on whether the user has Netscape or IE. I thought it was going to be straight froward but i'm having lots of problems.

Thanks.
 
Something along these lines is what you will need to do:

<script language=&quot;JavaScript&quot;>
//browser detect
browser_name = navigator.appName;
browser_version = parseFloat (navigator.appVersion);
bname = &quot;Brold&quot;;
if (browser_name.indexOf(&quot;Netscape&quot;) { bname = &quot;NS&quot;; };
if (browser_name.indexOf(&quot;Microsoft Internet Explorer&quot;) { bname = &quot;IE&quot;; }

//set link to fit the browser type
switch(bname)
{case &quot;NS&quot; :
document.write(&quot;<a href=\&quot;/itc_detail.lasso?user=[field:'username']\&quot; target=\&quot;_blank\&quot;>&quot;);
break;
case &quot;IE&quot; :
document.write(&quot;<a whatever your IE link is>&quot;);
break;
}
</script>
 
Thanks pain4u. The code looks good but i really can't see a way to use. I actually have 4 hyperlinks using lasso if statements, i would be a nightmare trying to apply this. Sorry. I thought it would have been something simple i could attach to each link. Maybe it would be easier if someone could tell me why my images don't show in Nestcape with the javascript code im using at..

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top