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…

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?

No, I’m only loading a html file. And in this is a script link to the “core.js” & the “script.js”.

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?

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);

Found the problem!

When I define the event listener for ie, it should say:
:
:
…attachEvent(“onclick”…)

Heh, you got it!

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

Glad you figured it out.