SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    .* draziW tnioPetiS *. bronze trophy
    Join Date
    Jun 2004
    Location
    "Then I figure the most good good guy will win."
    Posts
    1,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE-only filter: Target IE 5.5.x --> 6.x/PC? Best way?

    Hi,

    What would be the best way to test for IE only, and IE less than 7 (without conditional comments)?

    I want to apply alphaImageLoader via a JS function, but I am not sure of best way to only target IE 5.5 --> 6/PC.

    Any tips?

    Many many thanks in advance.

    Cheers,
    Micky

  2. #2
    .* draziW tnioPetiS *. bronze trophy
    Join Date
    Jun 2004
    Location
    "Then I figure the most good good guy will win."
    Posts
    1,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Silly me, I just found this... I think it will help.

    :: crossing fingers ::

  3. #3
    .* draziW tnioPetiS *. bronze trophy
    Join Date
    Jun 2004
    Location
    "Then I figure the most good good guy will win."
    Posts
    1,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, this seems to test for all IE's:

    Code:
    	// Test for IE (5.0) || (5.5) || (6.0):
    	var x = document;
    	if(x.all && ((!x.fireEvent && !x.opera) || (x.fireEvent && !x.creatComment) || (x.fireEvent && x.createComment))) {
    		alert('IE');
    	}
    How to exclude IE7? I will post back if/when I figure that one out.

  4. #4
    .* draziW tnioPetiS *. bronze trophy
    Join Date
    Jun 2004
    Location
    "Then I figure the most good good guy will win."
    Posts
    1,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See any problems with this logic?

    Code:
    	// Test for IE (5.0) || (5.5) || (6.0) and not (7.0):
    	var x = document;
    	if(x.all && ((!x.fireEvent && !x.opera) || (x.fireEvent && !x.creatComment) || (x.fireEvent && x.createComment)) && !window.XMLHttpRequest) {
    		alert('IE');
    	}

  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Micky,

    It's "window.opera" instead of "document.opera".

    Why not use conditional comments or conditional compilation? It is the most forward compatible and fail-safe method of detecting a particular IE version.

    Regarding the article you linked to... I always liked Eddie and his work - but that article is very old. What it refers to as "object detection" is not what we mean by "object detection" today.

  6. #6
    .* draziW tnioPetiS *. bronze trophy
    Join Date
    Jun 2004
    Location
    "Then I figure the most good good guy will win."
    Posts
    1,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mike! Thanks for the quick reply.

    Quote Originally Posted by MikeFoster View Post
    It's "window.opera" instead of "document.opera".
    Ahhh, thanks! I was wondering about that.

    I am guessing this looks a little bit better:

    Code:
    var x = document;
    var y = window;
    if(x.all && ((!x.fireEvent && !y.opera) || (x.fireEvent && !x.creatComment) || (x.fireEvent && x.createComment)) && !y.XMLHttpRequest) {
    /* IE only and IE < 7.0: */
    }
    Quote Originally Posted by MikeFoster View Post
    Why not use conditional comments or conditional compilation? It is the most forward compatible and fail-safe method of detecting a particular IE version.
    Gosh, I would really like to do that... Hmm, you are giving me some ideas... I guess I could put the function within an <!--[if lt IE 7]> CC, and then call it from my main JS file... In Javascript, is there a good way to test to see if a function exists? if(window.function()) { function() }?

    I think I have to test some different approaches and get back to you. I am currently having issues with cookies and the mulitple install of IE! God, I really hate IE 6 and below... makes me want to quit computers.

    Hmmm, conditional compilation sounds like an interesting approach! I will have to research this some more. Thanks for tips... sometimes I am not sure what "keyword" to search for via Google.

    Quote Originally Posted by MikeFoster View Post
    Regarding the article you linked to... I always liked Eddie and his work - but that article is very old. What it refers to as "object detection" is not what we mean by "object detection" today.
    Ahhh, thanks for clarification.

    I just found that link via a Sitepoint search... I kinda had a feeling that it was a bit outdated.

    Thanks again Mike! You are always a great help!

  7. #7
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I think conditional comments are the cleanest way. You don't have to detect objects you're not going to use and it's infallible. I've done this and it works quite nicely.

    Put all your IE-only JS in an external file and put it in the head via conditional comments. Then test for the existence of the function in your main script:
    Code:
    function doStuff() {
       if (typeof(ieOnlyFunction) !== 'undefined') ieOnlyFunction();
       else { // stuff for everyone else }
    }

  8. #8
    .* draziW tnioPetiS *. bronze trophy
    Join Date
    Jun 2004
    Location
    "Then I figure the most good good guy will win."
    Posts
    1,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raffles View Post
    Code:
    function doStuff() {
       if (typeof(ieOnlyFunction) !== 'undefined') ieOnlyFunction();
       else { // stuff for everyone else }
    }
    Perfect! That sounds good to me.

    Many many thanks Raffles and Mike, I really appreciate both of your help(s?)! Lol, I am never sure how to word that... "Both of your helps"?

    Thanks thanks thanks!!!

    Off Topic:

    I may be back with a few more questions... I can not test anything atm -- Currently re-installing Multiple IE -- for some reason, after dinking with my privacy settings, IE6 would open and not allow me to interact with it! Going to de-frag, clean registry, and re-install Multiple IE.

  9. #9
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are very welcome, Micky

  10. #10
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No worries.

    "Both of your help" does sound a bit weird...


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
  •