IE 7 不显示简单的 JS 警报?

发布于 2024-07-09 04:46:39 字数 545 浏览 11 评论 0原文

尝试单击以下页面上的“打印”按钮: (链接已删除 - 共识是一切正常,问题是我的设置) 出于调试目的,我用一个简单的警报(“测试”)替换了一大块 JavaScript,但即使如此,我也没有在 IE7 中显示它。 它在 Safari、FF(Mac 和 PC)和 IE6 中工作得很好,但由于某种原因,它在 IE7 中不起作用。 供您参考,按钮中的代码是这样的:

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

/newsletter/print.js 中的 JS 是这样的:

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

任何人都可以帮助我理解是否有解决这个问题的方法,或者这是否与我的事实有关我在 Mac 上通过 Parallels 运行“IE7 Standalone”吗? 任何帮助是极大的赞赏。

谢谢, 麦克风

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

另类 2024-07-16 04:46:40

刚刚在 IE7 Vista 上测试了它,它工作得很好...你的代码看起来也不错,所以我认为这可能是你的设置有问题?

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?

浅唱々樱花落 2024-07-16 04:46:40

Javascript 可能在您的 IE7 特定设置中被禁用。 请参阅此链接如何启用它:
http://www.tranexp.com/win/JavaScript-enabling.htm

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

你是年少的欢喜 2024-07-16 04:46:40

可能是它缓存了旧版本的 js 文件? 尝试 ctrl-F5

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

z祗昰~ 2024-07-16 04:46:40

我猜您的其他 javascript 代码有错误,导致您的浏览器忽略其他所有内容。

您也可能想将该代码更改为
... onclick="makeNewWindow();返回 false" ...
为了避免混淆

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

爱的十字路口 2024-07-16 04:46:40

这可能不是最初的问题,但由于我遇到了同样的问题,我给出了我的发现,它对其他人可能有用。

事实上,我只是通过从 Windows 资源管理器打开 HTML 来对其进行测试,因此地址栏中有一个 file:// URL。
这在所有浏览器中都可以正常工作,除了 Internet Explorer 7(或许更高版本)。
事实上,当我在 IE7 中打开此文件时,我收到了有关带有脚本的本地文件的安全问题的警报。 他们有如此多的安全漏洞,以至于他们过度保护...

看来alert()只是在这种本地模式下被停用,而且我找不到启用它的安全设置(不是搜索得太难...)。< br>
我最终将文件放入本地 Apache 安装的 www 目录中(使用 WampServer 2,但其他发行版可能也可以),并通过 http 打开它: //localhost,并且alert()的行为在那里没问题...

我还发现地址栏中的javascript:alert("Foo");完全被停用了,令人恼火的“设计”选择……太方便了。

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.

零度° 2024-07-16 04:46:40

发布的第一个答案 - 即使用 href='javascript:void(0);' 而不是 href='#'。 在您的情况下,使用 href='javascript:yourFunction();' 它应该可以工作。 IE 似乎优先考虑 href 而不是 onclick(其他浏览器则不然)。 另外,如果您没有 href,则会收到页面未找到错误。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文