简体   繁体   English

警报消息在IE6-7-8中不起作用,但在IE9中,Mozilla可以正常工作

[英]Alert message doesn't work in IE6-7-8 but in IE9 , Mozilla it works good

every body, i need your help please. 每个人,我都需要您的帮助。 I'm working on a javascript code and i try to test it in my IE6 , IE7 , IE8 browsers but it doesn't works but in mozilla or IE9 it's good why?! 我正在使用JavaScript代码,我尝试在IE6,IE7,IE8浏览器中对其进行测试,但是它不起作用,但是在mozilla或IE9中,这很好吗?!

this my code. 这是我的代码。

<html>
<body>

<button onclick="myfun()">try it</button>

<script>
function myfun(){
alert("hello,it's me!");
}
</script>
</body>
</html>

i test also by making in the onclick button : "alert("ok");" 我也通过在onclick按钮上进行测试:“ alert(” ok“);” , also this : javascript:alert(); ,也这样:javascript:alert();

thanx a lot 非常感谢

Buttons in IE and other browsers cause the page to reload. IE和其他浏览器中的按钮会导致页面重新加载。 You need to return false in your function. 您需要在函数中返回false。

function myfun(){
  alert("hello,it's me!");
  return false;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM