chrome、附加 dom 元素和返回行为的大问题
我正在一个显然无法解决的问题中挣扎。
我正在为客户编写一个 jQuery 购物车(请参阅此处的演示: http://thisisnot2.fornacestudio.com/prodotto )。
购物车脚本正在大量操作 dom 元素。 问题是,将订单发布到表单页面后,如果您点击 Chrome 浏览器中的后退按钮,脚本将停止工作(例如:类别在单击后不会显示其内容)。
有人知道这可能是什么原因造成的吗?
谢谢!
I'm struggling myself in a apparently solution-less problem.
I'm writing a jQuery cart for a customer (see a demo here: http://thisisnot2.fornacestudio.com/prodotto ).
The cart script is working heavily manipulating dom elements.
The problem is that after posting the order to the form page, if you hit the back button in the browser in Chrome the script stops working (for example: categories don't reveal their content after being clicked).
Does someone know what could cause this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,如果您不知道错误来自 suchi-cart.js 中的第 351 行,
形式为
object has no method 'modal'
,我还没有弄清楚为什么,因为我看到了最初通过硬刷新访问页面以及导航离开和返回时页面上包含的脚本。编辑:
在进一步研究脚本后,我注意到您在页面顶部使用了
lazyload
通过 googlehttps://ajax.googleapis.com/ajax/libs/ 包含 jQuery 1.6.2 jquery/1.6.2/jquery.min.js
然后在你的 head 标签中,你还可以通过以下方式加载 jQuery 1.6.1 的本地副本
<脚本类型='text/javascript' src='http://thisisnot2.fornacestudio.com/wp-includes/js/jquery/jquery.js?ver=1.6.1'> ;
最后,在页面的最底部,您可以通过以下方式包含 simplemodal 脚本
<脚本类型=“text/javascript”src=“http://thisisnot2.fornacestudio.com/wp-content/themes/notatemplate/cart/jquery.simplemodal.1.4.1.min.js”>
我的理论是对页面进行硬刷新,首先加载两个 jQuery 脚本,然后加载 simplemodel 脚本,当然它扩展了它的功能
.model()
方法以及未添加到 jQuery 对象上的内容。但是,当您离开页面并返回时,通过
加载的脚本 jQuery 1.6.1 和 simplemodel 插件会立即加载,但通过 Google 包含的 jQuery 1.6.2 的 LazyLoad 不会运行通过缓存,因为它是一个脚本,因此在前两个脚本将 jQuery 对象覆盖为 1.6.2 并删除加载到对象中的 simplemodal 脚本后加载。
因此,您需要从页面中删除延迟加载 jQuery。
Well if you didn't know the error is coming from line 351 in suchi-cart.js
In the form of
object has no method 'modal'
, I haven't figured out why exactly since I see the script included on the page when hitting the page initially with a hard refresh and when navigating away and going back.Edit:
Upon looking into the script more I noticed your using a
lazyload
at the top of the page to including jQuery 1.6.2 via googlehttps://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
Then in your head tag you also load a local copy of jQuery 1.6.1 via
<script type='text/javascript' src='http://thisisnot2.fornacestudio.com/wp-includes/js/jquery/jquery.js?ver=1.6.1'></script>
Finally at the very bottom of the page you include your simplemodal script via
<script type="text/javascript" src="http://thisisnot2.fornacestudio.com/wp-content/themes/notatemplate/cart/jquery.simplemodal.1.4.1.min.js"></script>
My theory is on a hard refresh of the page the two jQuery scripts are loading first followed by the loading for the simplemodel script which of course extends its
.model()
method and what not onto the jQuery object.But when you leave the page and go back the scripts loaded via
<script>
jQuery 1.6.1 and simplemodel plugin load instantly but the LazyLoad'd include of jQuery 1.6.2 via Google doesn't run through cache since its a script and thus is loading after the first two scripts overwriting the jQuery object to 1.6.2 and removing the simplemodal script loaded into the object.So you need to remove lazy loading jQuery from your page.