Javascript在IE8中不起作用 [英] Javascript does not work in IE8

查看:130
本文介绍了Javascript在IE8中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下JavaScript适用于IE7,但不适用于IE8:

The following JavaScript works on IE7 but not on IE8:

onclick=history.back(1) or history.go(-1)

关于为什么会出现这种情况以及如何克服它的任何建议。

Any suggestions on why this is the case and how to overcome it.

推荐答案

您是否尝试过:

onclick="history.back()"

带引号?

并且,回应你的陈述它不起作用: au contraire,mon ami。

And, responding to your statement that it doesn't work: au contraire, mon ami.

以下两个文件在我的IE8安装上正常运行,使用文件 x1.html

The following two files run fine on my IE8 install, using the files x1.html:

    <html><head></head><body>
        X1
        <hr>
        <a href="x2.html">x2</a>
    </body></html>

x2.html

    <html><head></head><body>
        X2
        <hr>
        <button onclick="history.back()">Back!</button>
    </body></html>

当我加载 x1 时,我可以移动到 x2 的链接,然后按钮移回 x1

When I load x1, I can move to x2 with the link, then the button moves back to x1.

这适用于所有三种兼容模式,因为它必须是浏览器上影响此设置的设置。

This works in all three compatibility modes, ergo it must be a setting on your browser which is affecting this.

我必须做的一件事就是这个工作是去工具 - >互联网选项 - >高级 - >安全性并选择允许活动内容在我的电脑上的文件中运行,因此几乎可以肯定,浏览器中的安全设置会让您感到悲伤。

One thing I had to do to get this to work was to go to Tools -> Internet Options -> Advanced -> Security and select Allow active content to run in files on My Computer, so it's almost certainly a security setting in your browser which is causing you grief.

这篇关于Javascript在IE8中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆