【问题标题】:Button doesn't trigger the corresponding action (both tag button and input type=button)按钮不触发相应的动作(标签按钮和输入类型=按钮)
【发布时间】:2013-07-19 04:59:21
【问题描述】:

我的 jquery 代码适用于 Chrome、Firefox、> IE8,但在 IE8 上似乎没有加载 jquery 和 jquery ui。

Javascript 已启用。

我使用<meta http-equiv="X-UA-Compatible" content="IE=7,IE=8" />,因为我在 IE9 上遇到了一些问题

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=8" />
<link href="css/my.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<link href="css/jquery-ui-timepicker-addon.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
         $(function(){
         }); // Sorry, really it's so and not only }
</script>
</head>

有什么建议吗?我应该检查什么?

编辑

通过改变

<meta http-equiv="X-UA-Compatible" content="IE=7,IE=8" />

<meta http-equiv="X-UA-Compatible" content="IE=8" />

解决了 IE8 上的大部分问题。

唯一仍然存在的问题是弹出窗口:

当有触发弹窗的按钮时,点击弹窗“OK”不会触发相应的动作(按钮在a标签内)。

【问题讨论】:

  • 不应该是$(function(){ //code here });还是(function($){})(jQuery);
  • “在 IE8 上没有加载” - 为什么没有加载? Javascript 控制台中是否有一些错误?
  • 不要忘记点击答案左上角的复选标记来接受正确答案
  • 所以....这仍然是一个问题吗?修复错字是否解决了问题?查看您的代码,我认为它没有理由在 IE8 中不起作用。
  • 您也可以在IE8 中按f12check How to use F12 Developer Tools to Debug your Webpages, if needed 进行调试。

标签: javascript jquery button internet-explorer-8 popup


【解决方案1】:

你试过了吗?

<meta http-equiv="X-UA-Compatible" content="IE=8,IE=EDGE" />

【讨论】:

【解决方案2】:

你能不能把它放在一个 jQuery.Ready 函数中,看看它在浏览器之间的工作是否更一致?我看到 cmets 使用不同的格式提出了同样的建议:

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=8" />
<link href="css/my.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<link href="css/jquery-ui-timepicker-addon.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
         $(document).ready(function(){
            // do something here...
         }); // Sorry, really it's so and not only }
</script>
</head>

..

还建议将您的 jquery、jquery-ui 和 jquery-ui css 和 jquery 验证更新到最新版本。您应该能够使用 modernizr javascript 库来检测您拥有的浏览器版本,然后应用这些元标记以满足您的需求。

这个link 将检测您使用modernizr 的浏览器版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-07
    • 1970-01-01
    • 2012-10-20
    • 1970-01-01
    • 1970-01-01
    • 2013-11-18
    • 1970-01-01
    相关资源
    最近更新 更多