Welcome to TalkGraphics.com

View Poll Results: Poll question

Voters
1. You may not vote on this poll
  • Dunno'

    1 100.00%
Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1
    Join Date
    Aug 2000
    Location
    Dallas, Tx
    Posts
    277

    Default

    Is there a sure way to detect IE or NS using javascript? I have a site that requires an HTML version along with the Flash site. I already know how to detect the Flash Player but Netscape really messes up my plans for an HTML site (that will need to be done with frames). Is there a way to detect the browser in order to re-direct the viewer to the appropriate site that is customized to that particular browser?

    Thanks in advance,
    IP

  2. #2
    Join Date
    Aug 2000
    Location
    Toronto, Ontario, Canada
    Posts
    432

    Default

    good poll choices, steve! [img]/infopop/emoticons/icon_smile.gif[/img]
    seriously, yes you can do it. have a look at some of the javascript resources at http://www.hudziak.com/haznet
    using macromedia's built-in code probably won't help much, but there are other pieces of code out there that you can use (the javascript tip of the week on browser detection helps)
    most people check for certain strings in the browser name and then a certain digit in the browser and then go from there. there are tons of scripts on the net, so you can probably dig up some pretty decent ones without too much trouble. when it comes to javascript, though, i generally have a look at netscape's devshed stuff from way back in the day (again, you can get there from haznet) as a starting point and go from there.


    hth,
    Deep (just a guy)
    <font face="arial" size="2">
    Pradeep Kumar Nair, B.Math
    Senior Web Designer
    http://www.blab.com
    ICQ: 39102360
    </font>
    hth,
    Deep (just a guy)
    --
    Pradeep Kumar Nair, B.Math
    CTO
    9 Story Entertainment
    http://www.9story.com
    IP

  3. #3
    Join Date
    Aug 2000
    Location
    Dallas, Tx
    Posts
    277

    Default

    I don't know a lot about javascript but I did manage to write one that seems to work very well with browser detection. Beleive me, it was a trial and error process because the end result was very confusing to me. It appears to detect the opposite browser and send the viewer to the correct browser. I noticed that it kept re-directing me to the opposite browser page so I just switched the hyperlinks. Maybe someone can tell us why this works. I tested it in NS 3.0, 4.6, 4.7 and 6.0. It also works with IE as far as I can tell (5.5 anyway). I am very confused as to why this works.

    Here is the code:
    <SCRIPT LANGUAGE="JavaScript">
    < !--
    var isNS=(navigator.appName=='Netscape');
    var isIE=(navigator.appName=='MSIE');

    if(!(isNS))
    {
    location.href='ie.htm';
    }
    else if(!(isIE))
    {
    location.href='ns.htm';
    }

    //-->
    </SCRIPT>

    Why does this work?

    Thanks in advance again,
    IP

  4. #4
    Join Date
    Aug 2000
    Location
    Dallas, Tx
    Posts
    277

    Default

    Oops.... Sorry for selecting this as a poll. Didn't realize I did. I was wondering why it was asking me for options. Dumb luck I guess.

    Thanks,
    IP

  5. #5
    Join Date
    Aug 2000
    Location
    Toronto, Ontario, Canada
    Posts
    432

    Default

    <SCRIPT LANGUAGE="JavaScript">
    < !--
    //grab some information from the browser
    //about itself. the appName is what
    //it calls itself
    var isNS=(navigator.appName=='Netscape');
    var isIE=(navigator.appName=='MSIE');

    //check to see if the browser name
    //contains "MSIE"
    if(isIE)
    {
    location.href='ie.htm';
    }

    //check to see if the browser name
    //contains "Netscape"
    else if(isNS)
    {
    location.href='ns.htm';
    }

    //if it's not netscape or ie, then
    //send it to some page which is safe
    //for ALL browsers
    else
    {
    location.href='textpage.htm';
    }

    //-->
    </SCRIPT>

    Well, it's not the most effective script I've seen, but it should server your purposes for now. I've added some comments to make it a bit more clear why it works

    <BR>hth,<br>Deep (just a guy)
    <font face="arial" size="2">
    Pradeep Kumar Nair, B.Math
    Senior Web Designer
    <a href="http://www.blab.com">http://www.blab.com</a>
    ICQ: 39102360
    </font>
    hth,
    Deep (just a guy)
    --
    Pradeep Kumar Nair, B.Math
    CTO
    9 Story Entertainment
    http://www.9story.com
    IP

  6. #6
    Join Date
    Aug 2000
    Location
    Dallas, Tx
    Posts
    277

    Default

    It looks as if you got it backwards. I see that you logically straightned out the code but it doesn't work that way (not to my experience anyway). All the browsers I tested it with send it to the wrong page. That's why it goes to the Netscape page if the browser is detected "MSIE" and goes to the Internet Explorer page if the detected browser is "NS". It seemed to work backwards for some reason and I can't understand that. I tested it on NS 3.0, NS 4.6, NS 4.7, NS 6.0 and IE 5.5. Test it, you'll see what I'm talking about. I'm not a javascript expert by any means so if this is something that I'm "just not getting", please excuse my inexperience and don't get offended that I'm questioning your feedback.

    Thanks a million,
    IP

  7. #7
    Join Date
    Aug 2000
    Location
    Toronto, Ontario, Canada
    Posts
    432

    Default

    WebMonkey Scripts has a script that should work for you, regardless of browser, etc. It's well documented, too - hopefully this helps out somewhat.


    hth,
    Deep (just a guy)
    <font face="arial" size="2">
    Pradeep Kumar Nair, B.Math
    Senior Web Designer
    http://www.blab.com
    ICQ: 39102360
    </font>
    hth,
    Deep (just a guy)
    --
    Pradeep Kumar Nair, B.Math
    CTO
    9 Story Entertainment
    http://www.9story.com
    IP

  8. #8
    Join Date
    Aug 2000
    Location
    Dallas, Tx
    Posts
    277

    Default

    Hi Deep,

    Thanks again for all of your help. I have been using Dreamweaver now for about a month. I got smart and converted from Front Page 2000. Anyway, I happened to notice this afternoon that there is a behavior that can be set with Dreamweaver to do this. Sorry for wasting your time. I was really just curious of why that script worked on the browsers I tested it on when it looks like a mess.

    Thanks for all your help in the past and in advance for future questions. Especially since this question wasn't related to Flash. Your dedication is much appreciated.
    IP

  9. #9
    Join Date
    Aug 2000
    Location
    Toronto, Ontario, Canada
    Posts
    432

    Default

    hey no prob! [img]/infopop/emoticons/icon_smile.gif[/img]

    incidentally, even though dreamweaver has its behaviors, i'd say that it would be a good idea for you to get used to using javascript and coding it by hand. you're getting to the point where wysiwyg editors are going to be a little bit beneath you soon. you'll start desiring functionality that they can't provide, or that will be easier to do without their nasty way of reformatting all your code. i've kept going to your site from time to time to keep an eye on your progress, and you're getting to the point where i'm sure you're going to want more control than any wysiwyg editor is going to give you.

    it's just a suggestion, but you might want to start teaching yourself a few more advanced tricks and techniques by hand. for the next few months or so, dreamweaver should be fine for you, and maybe afterwards you'll move to homesite. but i can see you switching to a combination of a wysiwyg and a text editor (like ultraedit or textpad or something) within the next year and a half, just to keep the most control over your pages. might as well start learning the techniques when you don't HAVE to so that you're not frustrated later on, hm? [img]/infopop/emoticons/icon_biggrin.gif[/img]

    good luck with everything!


    hth,
    Deep (just a guy)
    <font face="arial" size="2">
    Pradeep Kumar Nair, B.Math
    Senior Web Designer
    http://www.blab.com
    ICQ: 39102360
    </font>
    hth,
    Deep (just a guy)
    --
    Pradeep Kumar Nair, B.Math
    CTO
    9 Story Entertainment
    http://www.9story.com
    IP

  10. #10
    Join Date
    Dec 2000
    Location
    the twilight zone
    Posts
    1,238

    Default

    I also visited your site and cam back her to tell you that I'm really impressed. Efficient, fast loading and effective.
    Perhaps a hint, or, sorry, a new dimension to your quest: I prefer to use, and do use the OPERA browser. In my opinion it is the most reliable and the fastest.Even with a cable ISDN connection one sees the difference. For CSS, Opera is the best.
    I had no problem visiting your site but I was just wondering if you tried your site in Opera or not...
    IP

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •