,其余部分将被忽略。jquery load() 与 ie7 ie8 的问题
您好,由于某种原因,此代码无法在 ie7/ie8 下运行。
$('#cnt').load('./tiles/pages/'+ $name +'.php #'+$lang, showNewContent());
检索 php 文件中 ID 为 $lang 的部分似乎有问题。该代码适用于所有其他浏览器,如果我这样称呼它,它也适用于 ie7/ie8:
$('#cnt').load('./tiles/pages/'+ $name +'.php', showNewContent());
但我不喜欢这样。
知道为什么 ie7/ie8 会这样吗?好的 ie7 我知道 =>这是废话:-)
现在 php 文件只包含纯 html5,看起来像这样:
<article id="de">
<header>
<h2>Your article heading</h2>
<p>Lorem ipsum dolor sit amet.</p>
</header>
<h3>A smaller heading</h3>
<p>Lorem ipsum dolor sit amet</p>
<h3>A smaller heading</h3>
<p>Lorem ipsum dolor sit amet</p>
<footer>
<h3>About the author</h3>
<p>Lorem ipsum dolor sit amet</p>
</footer>
</article>
<article id="en">
<header>
<h2>Your article heading</h2>
<p>Lorem ipsum dolor sit amet.</p>
</header>
<h3>A smaller heading</h3>
<p>Lorem ipsum dolor sit amet</p>
<h3>A smaller heading</h3>
<p>Lorem ipsum dolor sit amet</p>
<footer>
<h3>About the author</h3>
<p>Lorem ipsum dolor sit amet</p>
</footer>
</article>
更新:
看起来,是 HTML5 标签把它抛弃了???我正在使用 Modernizr,有人想尝试一下吗?在 dom 中,仅加载
Hi this code does not run under ie7/ie8 for some reason.
$('#cnt').load('./tiles/pages/'+ $name +'.php #'+$lang, showNewContent());
It seems to have problems to retrieve the section in the php file with the id $lang. The code works in all other browsers, and it works in ie7/ie8 if I call it like that:
$('#cnt').load('./tiles/pages/'+ $name +'.php', showNewContent());
and I don't like that.
Any idea why ie7/ie8 behave this way? ok ie7 I know => it is crap :-)
For now the php file just contains plain html5 which looks like that:
<article id="de">
<header>
<h2>Your article heading</h2>
<p>Lorem ipsum dolor sit amet.</p>
</header>
<h3>A smaller heading</h3>
<p>Lorem ipsum dolor sit amet</p>
<h3>A smaller heading</h3>
<p>Lorem ipsum dolor sit amet</p>
<footer>
<h3>About the author</h3>
<p>Lorem ipsum dolor sit amet</p>
</footer>
</article>
<article id="en">
<header>
<h2>Your article heading</h2>
<p>Lorem ipsum dolor sit amet.</p>
</header>
<h3>A smaller heading</h3>
<p>Lorem ipsum dolor sit amet</p>
<h3>A smaller heading</h3>
<p>Lorem ipsum dolor sit amet</p>
<footer>
<h3>About the author</h3>
<p>Lorem ipsum dolor sit amet</p>
</footer>
</article>
UPDATE:
As it looks like, it is the HTML5 tags that throw it off??? I am using modernizr, anyone want to take a hit on that? In the dom only <article id="de" />
is loaded the rest is neglected.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更新1
你说调用不带#的代码是可以的,所以因为使用load方法和ID选择器你实际上获取了所有文档,但是jQuery只会将代码保留在指定的元素ID内,您可以简单地调用 load 方法而不使用 ID 选择器,然后仅保留您需要的元素并自行删除其余元素。
也许 URL 中的空格是问题所在,您可以尝试稍微避开它吗?
喜欢
或
Update 1
You said that calling the code without # works ok, so since with the load method and ID selector you are actually fetching all the document, but jQuery will only keep the code within the specified element ID, you could simply call the load method without an ID selector, then keep only the element you need and remove the rest yourself.
Maybe the space in the URL is the problem, could you try to escape it somewhat?
Like
or
可能为时已晚,但是您是否尝试在新加载的 html 上重新应用 Modernizr ?
Probably too late, but did you try re-applying modernizr on your newly loaded html?