• starmatt

    (@starmatt)


    This seems to be a documented issue with IE 6 & 7. If there’s a javascript that is too heavy, it throws up an error message (IE can’t open this site, operation aborted), then brings up the “page not loading” page. The solutions I have found online are these:

    1. put defer=”defer” into the script tag (this will cause it to wait until the page is loaded to run the script).

    2. Move the script to the body tag only and not subtags.

    Unfortunately, the script in question is a script I got from amazon for a widget, so I can’t alter the script itself. Also, moving the script moves the widget and putting defer=”defer” in the script tag just makes it not work at all in any browser.

    Has anyone else had this problem or have any good ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi

    (@esmi)

    Place the script call inside IE conditional comments

    Thread Starter starmatt

    (@starmatt)

    esmi, I don’t quite follow the logic. If I put it in conditional comments, I can load the script only in IE (or some versions of IE), but the problem only exists in IE. Is there a conditional comment to exclude IE?

    esmi

    (@esmi)

    Yes – you can exclude not only IE but specific versions of IE. I used this approach when developing a Nimbit widget that collapsed in earlier versions of IE.

    echo $before_widget;
    echo "<!--[if gte IE 8]><!-->\n"; // Hide from IE7 or earlier (js errors in nimbit scripts)
    if ( $title ) echo $before_title . $title . $after_title;
    <script src="http://example.com/includes/some_script.js" type="text/javascript"></script>
    [ any other code I wanted to exclude ]
    echo "<!--<![endif]-->\n";
    echo $after_widget;
    Thread Starter starmatt

    (@starmatt)

    I’m only putting the html text in a text widget in the sidebar, so php is out. I suppose I could put it in the sidebar in the theme, but I’d like to avoid that if possible.

    My question is more how this affects other browsers. At first pass, this looks like I can have the script run only in ie8 or newer, but what does that do for firefox and others? At present, the script works fine in other browsers.

    Thread Starter starmatt

    (@starmatt)

    I figured out how to do it like so:

    <![if !(lt IE 8)]>
    <SCRIPT type="text/javascript" src="javascript url"> </SCRIPT>
    <![endif]>

    Using < instead of <!-- for the beginning keeps other browsers from thinking it’s a comment. Also needs a > instead of a --> at the end.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘javascript causes ie problem’ is closed to new replies.