SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: IE and JS

  1. #1
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE and JS

    Hi

    I've attached a JS program to this thread.
    What it should do is, once click on a link with the paticular class, the browser should alert you that you are leaving the site.

    I've declared in the program the code needed to work in IE.
    I have tested it in various browsers and it works, but I can't seem to find the problem why its not working in IE. When the browser loads the html file it does say that the active content is blocked, but you can click a popup window to allow the active content - which I did.

    Please help...
    Attached Files Attached Files

  2. #2
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    When the browser loads the html file it does say that the active content is blocked, but you can click a popup window to allow the active content - which I did.
    Weird, it doesn't do that for plain ol' JS. Is there something more than JS involved here?

  3. #3
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, I'm only loading a html file. And in this is a script link to the "core.js" & the "script.js".

  4. #4
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    If it's not ginormous, can you just post it here in [code] tags?

    But that click-to-activate looks really suspicious... IE does that with Flash and Active X sometimes... but plain ol' JS shouldn't, really.

    Sitepoint has a popup that asks are you sure you want to log out? Which I normally don't see as I have JS off. So, they do it in a way that works with IE.

    I suppose, just to be sure you don't have some wiggy security setting in your IE, can you verify that SitePoint's popup works for you in IE?

  5. #5
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the code:

    var Anchor =
    {
    init: function()
    {
    var link = Core.getElementsByClass("leaveSite");

    for (var i = 0; i < link.length; i++)
    {
    if (typeof link[i].addEventListener != "undefined")
    {
    link[i].addEventListener("click", Anchor.clickListener, false);
    }
    else if (typeof link[i].attachEvent != "undefined")
    {
    link[i].attachEvent("click", Anchor.clickListener);
    }
    }
    },

    clickListener: function(event)
    {
    if (typeof event == "undefined")
    {
    event = window.event;
    }

    if (!confirm("Are you sure you want to leave this site?"))
    {
    event.preventDefault();
    }
    else
    {
    event.returnValue = false;
    }
    }
    };

    Core.start(Anchor);

  6. #6
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found the problem!

    When I define the event listener for ie, it should say:
    :
    :
    ...attachEvent("onclick"....)

  7. #7
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Heh, you got it!

    IE still likes the old "on" prefix while everyone else does not like it.

    Glad you figured it out.


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
  •