IE 7 not displaying a simple JS Alert?
Asked Answered
M

6

2

Try clicking on the "Print" button on the following page: (link removed - consensus is that everything was working fine and the problem was my setup) For debugging purposes, I've replaced a chunk of javascript with a simple alert("test"), and even that isn't showing up in IE7 for me. It works totally fine in Safari, FF (Mac and PC) and IE6, but for some reason it's not working in IE7. For your reference, the code in the button is this:

<a onclick="makeNewWindow()" href="#"><img src="/print.gif"/></a>

And the JS inside /newsletter/print.js is this:

function makeNewWindow() {
   alert("test");   
}

Can anyone help me understand if there's a way around this, or if this has something to do with the fact that I'm running "IE7 Standalone" via Parallels on my Mac? Any help is greatly appreciated.

Thanks, Mike

Mast answered 24/11, 2008 at 4:29 Comment(2)
nothing with your question, but instead href="#" use href="javascript:void(0);" so you can avoid those jumps when someone clicks in the image... as I said, it's not your question but to improve your code in the future :)Suprematism
Do you have somekind of aggressive popup blocker installed ?Rust
C
5

Just tested it on IE7 Vista and it worked fine... Your code looks sound as well, so I think it might be an issue with your setup?

Christiansen answered 24/11, 2008 at 4:36 Comment(0)
N
4

Javascript is probably disabled in your particular setup of IE7. See this link how to enable it : http://www.tranexp.com/win/JavaScript-enabling.htm

Nasa answered 24/11, 2008 at 6:52 Comment(0)
B
3

could be that it's caching an older version of the js file? try ctrl-F5

Billbug answered 24/11, 2008 at 7:40 Comment(0)
V
3

I'm guessing that you have an error with OTHER javascript code which is causing your browser to just ignore everything else.

Also you may want to change that code to ... onclick="makeNewWindow();return false" ... in order to avoid confusion

Vyner answered 24/11, 2008 at 7:43 Comment(0)
L
2

It might not be the original issue, but since I had the same problem, I give my finding, it can be useful to somebody else.

In fact, I tested an HTML by just opening it from Windows Explorer, so I have a file:// URL in the address bar.
This works fine in all browsers, except Internet Explorer 7 (and maybe above).
In fact, when I opened this file in IE7, I got an alert about security issues with a local file with script. They got so many security breaches that they are overly protective...

It appeared that alert() is just deactivated in this local mode, and I couldn't find security settings to enable it (not searching too hard...).
I finally dropped the file in the www directory of my local Apache install (using WampServer 2 but other distributions are fine, probably), and opened it via http://localhost, and the behavior of alert() was OK there...

I also discovered that javascript:alert("Foo"); in the address bar is just totally deactivated, an infuriating "design" choice... it was just too convenient.

Lumber answered 16/6, 2011 at 15:8 Comment(0)
H
0

The first answer posted - ie, use href='javascript:void(0);' instead of href='#'. In your case, use href='javascript:yourFunction();' and it should work. IE appears to give precedence to href over onclick (other browsers don't). Also, if you don't have an href, you get a page not found error.

Homesick answered 2/4, 2012 at 13:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.