简体   繁体   English

jQuery的弹出窗口只能在IE浏览器,而不是在Firefox

[英]jquery popup only works in ie and not in firefox

I have the following code. 我有以下代码。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/smoothness/jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>
<script type="text/javascript">
        $(document).ready(function () {
            $("#submit").click(function () {
                $("#dialog").dialog({modal: true, height: 590, width: 1005 });
            });
        });
    </script>
</head>

<body>
<a href="" id="submit">
<div id="dialog" title="Contact form">
   <p>appear now</p>
 </div>
</body>
</html>

when i run this code in ie it works fine and pops up the window no problem. 当我在即运行此代码时,它工作正常,并弹出窗口没问题。 But when i run this in firefox it just refreshes the page. 但是,当我在Firefox中运行它时,它只会刷新页面。 Anyone know how to fix this and why its happening? 有人知道如何解决此问题,为什么会发生?

I see 2 things 我看到两件事

1) Prevent link default behavior (navigate to href url, in this case, current page) using event.preventDefault 1)使用event.preventDefault防止链接默认行为(导航到href url,在本例中为当前页面)

$("#submit").click(function (e) {
    e.preventDefault():
    $("#dialog").dialog({modal: true, height: 590, width: 1005 });
});

2) Your a tag is incorrect, it never closes. 2)您a标签不正确,它永远不会关闭。 Not sure if this is a copy paste mistake or your real html. 不知道这是一个复制粘贴错误还是您的真实HTML。

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

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