Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IE issue with javascript code

    Hello Everyone,
    I have an issue with IE (6, 7 and 8). I have a js file, which is importing another js file, in which is defined a variable and is being accessed in the former mentioned js file. In IE, the IE developer toolbar shows that the call to the variable is happening only after the js file is being imported. But rendering wise that is not happening and IE is throwing a script error saying the variable is not defined.
    In Firefox, this works fine with absolutely no issues or script errors (which is confirmed using firebug).
    Is this a known issue with IE or is it something else?
    Please help me out people.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    This may be the old IE bug where a short delay of say 50ms is required before the variable is accessed.

    Code:
    var tim = setTimeout("getTheValue()",50);
    var val;
    
    function getTheValue() {
    val = whatever;
    }

  • #3
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot for your time.
    I tried out what you have suggested. It still is giving the same undefined error. Is there any chance that IE is unable to locate the file in the mentioned path? AFAIK, that should not happen either.
    Please do let me know.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    As you have not posted any code it is not easy to identify your problem.

    Please post your relevant (stripped down) code. Then we can try to work out what is wrong.

  • #5
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Here you go,

    var += "<script type=\"text/javascript\" src=\"/objects/javascript/smileys.js\">";
    var += "</script>";
    var += "<script type=\"text/javascript\">";
    var += "var1.containers = ['smileywide'];";
    var += "obj.var1.init (var1);";
    var += "</script>";

    IE throws 2 script errors, "var1 is undefined" and "obj is undefined", simultaneously.

  • #6
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Got it. Thanks to Philip for giving me a something to start with. Yes, IE has a stupid lag due to which i could not use any of the js components, soon after it was imported. Hence i imported it at the load of the page and now it is fine.
    Thanks a lot!


  •  

    Posting Permissions

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