jQuery .load() - 角落插件在 IE 中不起作用 - Firefox 可以
我有两个简单的页面用于测试。
在我的第一页上,我使用 $.load()
从第二页加载 div
。
两个页面都包含用于转弯的插件。如果我加载从第二页加载 div 的第一页,则转弯不起作用。但是,如果我自己加载第二页,则转弯确实有效,因此它与 $.load() 有关。
以下是第 1 页中的一些代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#load").load('testLoadCornering2.aspx #loadMe');
});
</script>
<script src="resources/js/curvycorners.js" type="text/javascript"></script>
<script src="resources/js/curvycorners.src.js" type="text/javascript"></script>
<link href="resources/css/main.css" rel="stylesheet" type="text/css" />
<link href="resources/css/buttons.css" rel="stylesheet" type="text/css" />
<link href="resources/css/confirm.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div id="load" class="BWTable">
</div>
</form>
</body>
</html>
您会看到页面尝试加载第二个 div。
第二页:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="resources/js/curvycorners.js" type="text/javascript"></script>
<script src="resources/js/curvycorners.src.js" type="text/javascript"></script>
<link href="resources/css/main.css" rel="stylesheet" type="text/css" />
<link href="resources/css/buttons.css" rel="stylesheet" type="text/css" />
<link href="resources/css/confirm.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div id="loadMe" class="BWTable">
<p>
Test Test Test Test Test Test Test
</p>
</div>
</form>
</body>
</html>
以及它用于圆角的 CSS(以及圆角插件):
background-image: url( '../../images/wp_form2.gif' );
border: solid 1px #000000;
margin-left: auto;
margin-right: auto;
text-align: center;
color: white;
-moz-border-radius: 10px; /* Rounded corners plugin */
-webkit-border-radius: 10px; /* Rounded corners plugin */
在 Firefox 中,这工作正常 - 但在 IE 中(特别是我一直在尝试的版本 8),角从不圆角。
重申一下,只有在使用 .load() 方法时,才能正确手动转到 IE 8 角的第二页。
任何帮助表示赞赏。
注意:我知道我不需要在两个页面等上添加样式表,因为它们应该从第一页加载,但我添加它们是为了向您展示它正在尝试执行的操作的完整代码。 谢谢, 瑞奇
I have two simple pages I'm using for testing.
On my first page, I use $.load()
to load a div
from the second page.
Both pages contains the plugin to do the cornering. If I load the first page which loads the div from the second page, the cornering does not work. However, if I load the second page myself, the cornering does work so it's to do with $.load().
Here's some code, from page 1:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#load").load('testLoadCornering2.aspx #loadMe');
});
</script>
<script src="resources/js/curvycorners.js" type="text/javascript"></script>
<script src="resources/js/curvycorners.src.js" type="text/javascript"></script>
<link href="resources/css/main.css" rel="stylesheet" type="text/css" />
<link href="resources/css/buttons.css" rel="stylesheet" type="text/css" />
<link href="resources/css/confirm.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div id="load" class="BWTable">
</div>
</form>
</body>
</html>
You see the page trying to load the second div.
And the second page:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="resources/js/curvycorners.js" type="text/javascript"></script>
<script src="resources/js/curvycorners.src.js" type="text/javascript"></script>
<link href="resources/css/main.css" rel="stylesheet" type="text/css" />
<link href="resources/css/buttons.css" rel="stylesheet" type="text/css" />
<link href="resources/css/confirm.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div id="loadMe" class="BWTable">
<p>
Test Test Test Test Test Test Test
</p>
</div>
</form>
</body>
</html>
And the CSS it uses for the rounding (along with the rounded corners plugin):
background-image: url( '../../images/wp_form2.gif' );
border: solid 1px #000000;
margin-left: auto;
margin-right: auto;
text-align: center;
color: white;
-moz-border-radius: 10px; /* Rounded corners plugin */
-webkit-border-radius: 10px; /* Rounded corners plugin */
In Firefox, this works fine - but in IE (specially version 8 I've been trying) the corners are never rounded.
To reiterate, manually going to the second page in IE 8 corners correctly, it's only when the .load() method is used.
Any help appreciated.
Note: I'm aware I shouldn't need to add the style sheets on both pages etc as they should be loaded from the first page, but I've added them to show you the full code of what it's trying to do.
Thanks,
Ricky
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里的问题是,curvycorners 只会在 IE 中出现,因为 Firefox 完全支持 CSS3 圆角,所以当它在 Firefox 中工作时,这只是因为 curvycorners 没有尝试做任何事情。
您的 JQuery 加载被放置在文档就绪块中,因此在加载整个页面(包括(我相信)javascript)之前不会执行,因此 curvycorners 在加载第二个页面 div 之前运行。您需要找到一种方法来在第二个页面 div 之后加载 curvycorners 脚本,或者找出如何在加载第二个页面 div 后调用 curvycorners 来重新解析页面。
来自 curvycorners 文档:
The issue here is that curvycorners will only spring into life for IE as Firefox fully supports the CSS3 rounded corners so while it's working in Firefox, that's only because curvycorners isn't attempting to do anything.
Your JQuery load is placed within a document-ready block and so won't execute until the whole page has loaded, including (I believe) the javascript, so curvycorners is running before your second page div is loaded. You need to find a way to either load the curvycorners script after your second page div or find out how to call curvycorners to reparse the page once it has loaded the second page div.
From the curvycorners documentation:
谢谢拉撒路。你让我走上了正确的道路,我已经找到了解决方案,这有效。我现在感觉有点傻!
再次感谢。
第 1 页:
第 2 页:
Thanks Lazarus. You put me on the right tracks and I've worked out the solution, this works. I feel a bit silly now!
Thanks again.
Page 1:
Page 2: