Results 1 to 9 of 9

Thread: Trying to fix a if brower='IE'...

  1. #1
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Trying to fix a if brower='IE'...

    Code:
    var IE = 'Microsoft Internet Explorer'
    var FF = 'Netscape'
    var browser = '+navigator.appName+'
    
    if (browser =='IE')
    {
    
    alert("this page does not support internet explorer. You will be redirected to another page with more information.');
    
    window.location.replace("ieusers.html");
    
    }
    trying to fix so an alertbox pops up and then when u click the OK, u get redirected to ieusers.html.

    how come my homemade scripts never work?

  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Try this:
    Code:
    <!--[if IE]>
    <meta http-equiv="refresh" content="3;url=ieusers.html">
    <![endif]-->
    It'll redirect to the IE page in 3 seconds and requires no JavaScript.
    You need to put this in the <head> section with the other <meta...> tags.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  3. #3
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by NineTwoZero View Post
    var browser = '+navigator.appName+'
    This statement declares a variable, browser, initialised with a string literal. This literal contains the nineteen characters, "+navigator.appName+". What you're trying to do is assign the value of a property to the variable, which should be written:

    Code:
    var browser = navigator.appName;
    That said, the technique you're trying to employ - browser detection - is flawed and unreliable. Don't do it.

    alert("this page does not support internet explorer. ...
    Then that page needs to be fixed. Creating two or more separate documents for different groups of visitors just adds unnecessary work for you.

    The use of a dialogue box is questionable: why should the user need to know that you want to use two different documents? Implementation details should be kept from users. At best, the user won't care, at worst, they won't understand what's happening, and will become confused thinking that something's wrong.

    Mike

  4. #4
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    im still polishing the site but feel free to have a peek. http://920.ninetwozero.com
    doesnt work in IE (as far as i know.)
    Quote Originally Posted by mwinter View Post
    This statement declares a variable, browser, initialised with a string literal. This literal contains the nineteen characters, "+navigator.appName+". What you're trying to do is assign the value of a property to the variable, which should be written:

    Code:
    var browser = navigator.appName;
    That said, the technique you're trying to employ - browser detection - is flawed and unreliable. Don't do it.


    Then that page needs to be fixed. Creating two or more separate documents for different groups of visitors just adds unnecessary work for you.

    The use of a dialogue box is questionable: why should the user need to know that you want to use two different documents? Implementation details should be kept from users. At best, the user won't care, at worst, they won't understand what's happening, and will become confused thinking that something's wrong.

    Mike
    i dont have a clue why it aint workin in ie so im was gonna redirect to ieusers.html where u can go straight to the forum or getfirefox.com lol

    Quote Originally Posted by tech_support View Post
    Try this:
    Code:
    <!--[if IE]>
    <meta http-equiv="refresh" content="3;url=ieusers.html">
    <![endif]-->
    It'll redirect to the IE page in 3 seconds and requires no JavaScript.
    You need to put this in the <head> section with the other <meta...> tags.
    aight will test it. thanks m8. =D

  5. #5
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by NineTwoZero View Post
    http://920.ninetwozero.com
    doesnt work in IE (as far as i know.)
    It doesn't render anything in IE, and probably other browsers too, because you're trying to use XML-like syntax in a HTML document. This is why I constantly say that unless authors understand XML (and XHTML) throughly, they should not attempt to use it on the Web. It only leads to trouble.

    Mike

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yeah, Mike's right. This is wrong:

    Code:
    		<script src="super.js" type="text/javascript"/>
    		<!--[if IE]>
    			<meta http-equiv="refresh" content="0;url=ieusers.html">
    		<![endif]-->
    		<script src="menu.js" type="text/javascript"/>
    It should be:

    Code:
    <script src="super.js" type="text/javascript"></script>
    <script src="menu.js" type="text/javascript"></script>
    Then you wouldn't even need the redirect.

    From the point of view of proper coding, there are other problems. But that change will allow the page to render fine in IE.

    You may not want to code to spec. But, at least don't use self closing tags for tags that normally have a separate closing tag.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mwinter View Post
    It doesn't render anything in IE, and probably other browsers too, because you're trying to use XML-like syntax in a HTML document. This is why I constantly say that unless authors understand XML (and XHTML) throughly, they should not attempt to use it on the Web. It only leads to trouble.

    Mike
    so basiclly its coz of my doctype?

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    No, it is your misuse of self closing tags for your script tags. See my previous post in this thread. The DOCTYPE isn't proper for what you are doing, no. But IE will overlook that, not the invalid (for HTML - all that IE understands) tags though.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    No, it is your misuse of self closing tags for your script tags. See my previous post in this thread. The DOCTYPE isn't proper for what you are doing, no. But IE will overlook that, not the invalid (for HTML - all that IE understands) tags though.
    alright. thx for the help :]

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
  •