用户
 找回密码
 入住 CI 中国社区
搜索
12
返回列表 发新帖
楼主: scarlett
收起左侧

[视图] javascript 不执行,刷新后才执行

[复制链接]
发表于 2017-9-20 22:05:56 | 显示全部楼层
jquery 没先引入把
 楼主| 发表于 2017-11-29 11:39:14 | 显示全部楼层

在别的网页上也遇到这种问题。

终于解决了,在a 标签上添加 external就可以了

<a rel="external" href=“”>
 楼主| 发表于 2017-11-29 11:41:19 | 显示全部楼层
本文最初的问题解决方案是将script写在 window.onload中。

但是又在其它页面遇到了同样的js刷新后才执行的问题,解决办法是在a标签上加上 external。
发表于 2017-11-30 14:21:39 | 显示全部楼层
scarlett 发表于 2017-11-29 11:41
本文最初的问题解决方案是将script写在 window.onload中。

但是又在其它页面遇到了同样的js刷新后才执行的 ...

解决方案太奇怪了。估计会有很多兼容问题和安全问题。
应该直接用php解决到问题。
 楼主| 发表于 2018-1-21 08:57:19 | 显示全部楼层
Linking within a multi-page document
A single HTML document can contain one or many "page" containers simply by stacking multiple divs with a data-role of "page". This allows you to build a small site or application within a single HTML document; jQuery Mobile will simply display the first "page" it finds in the source order when the page loads.

If a link in a multi-page document points to an anchor (#foo), the framework will look for a page wrapper with that id (id="foo"). If it finds a page in the HTML document, it will transition the new page into view. You can seamlessly navigate between local, internal "pages" and external pages in jQuery Mobile. Both will look the same to the end user except that external pages will display the Ajax spinner while loading. In either situation, jQuery Mobile updates the page's URL hash to enable Back button support, deep-linking and bookmarking.

It's important to note that if you are linking from a mobile page that was loaded via Ajax to a page that contains multiple internal pages, you need to add a rel="external" or data-ajax="false" to the link. This tells the framework to do a full page reload to clear out the Ajax hash in the URL. This is critical because Ajax pages use the hash (#) to track the Ajax history, while multiple internal pages use the hash to indicate internal pages so there will be conflicts in the hash between these two modes.

For example, a link to a page containing multiple internal pages would look like this:

<a href="multipage.html" rel="external">Multi-page link</a>
 楼主| 发表于 2018-1-21 08:58:01 | 显示全部楼层
<a data-ajax="false" >这样也可以

本版积分规则