如何使页面真正重装 [英] How to make the page really reload

查看:192
本文介绍了如何使页面真正重装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的Greasemonkey脚本(写的另外codeR - 布鲁克·亚当斯),加载顺序包含数组的code开头的页面。 <一href="http://stackoverflow.com/questions/12260455/how-to-open-a-list-of-pages-automatically-and-sequentially/12261238#comment16440466_12261238">How自动打开的页面列表,依次?

  // == UserScript ==
// @name多页,各种各样多点会议幻灯片
// @include http://google.com/*
// @包括HTTP://站点2 / *
// @包括HTTP:// site3 / *
// @包括HTTP:// site4 / *
// @grant GM_addStyle
// == / UserScript ==
/ *  - 的@grant指令是需要解决的一大设计
    在通用汽车1.0的变化推出。
    它恢复了沙箱。
* /

VAR urlsToLoad = [
    http://google.com/
    ,HTTP://站点2 / SomePage的/
    ,HTTP:// site3 / SomePage的/
    ,HTTP:// site4 / SomePage的/
]。

/ * ---因为很多这些网站的加载大型画册,Chrome的和
    Firefox的喷射可以将图像之前触发一个很好的协议(S)
    完成加载。
    因此,确保脚本火灾后负荷:
* /
window.addEventListener(加载,FireTimer,假);
如果(document.readyState ==完成){
    FireTimer();
}
通过很乖AJAX加载// ---抓住新的页面。
window.addEventListener(hashchange,FireTimer,假);

功能FireTimer(){
    的setTimeout(GotoNextURL,5000); // 5000 ==5秒
}

传播GotoNextURL(){
    VAR numUrls = urlsToLoad.length;
    VAR urlIdx = urlsToLoad.indexOf(location.href);
    urlIdx ++;
    如果(urlIdx&GT; = numUrls)
        urlIdx = 0;

    location.href = urlsToLoad [urlIdx]
}
 

在问题出现时,我有2页相同的网站进行顺序装:脚本将停止工作,因为该网站使用了AJAX才能有更快的加载其网页

我怎么能强迫该脚本完全重新加载页面?

正如你可以看到他已经尝试过:

  // ---渔获很乖AJAX加载新的页面。
window.addEventListener(hashchange,FireTimer,假);
 

要解决这个问题,但预期它不能正常工作。

在特定的网站,让我这个问题是ink361.com。 我已经创造了他的源代码的一个例子的的jsfiddle: http://jsfiddle.net/XjjfK/

在此先感谢。

解决方案

我无法登录,但脚本工作完美的我。
我安装脚本完全一样的下方,它循环的3 ink361.com页之间,就像预期。

有些事情你做/检查:

  1. 您使用您的其他脚本(或任何其他通用脚本)在同一网页?

  2. 当您浏览ink361.com,什么是Greasemonkey的菜单显示?

  3. 这听起来像安装脚本不具有 hashchange code - 它应该可以在该网站上,因为它的的更新#标签。

    1. 卸载脚本。
    2. 重新启动Firefox浏览器。
    3. 重新安装脚本。

  4. 发表确切,未经编辑的脚本 - 您使用的是 - 在 pastebin.com ,并链接到它在这里。

  5. 卸载任何其他脚本ink361.com,并安装下面只是剧本。
    它的工作原理?
    如果不是,后控制台日志,或Firebug的日志,在 pastebin.com

// == UserScript == // @name _del我 // @namespace _PC // @include http://ink361.com/* // @grant GM_addStyle // == / UserScript == / * - 的@grant指令是需要解决的一大设计     在通用汽车1.0的变化推出。     它恢复了沙箱。 * / 的console.log(开始,时间()); VAR urlsToLoad = [     http://ink361.com/#/users/206053596/photos     http://ink361.com/#/users/199101377/photos     http://ink361.com/#/users/203767882/photos ]。 / * ---因为很多这些网站的加载大型画册,Chrome的和     Firefox的喷射可以将图像之前触发一个很好的协议(S)     完成加载。     因此,确保脚本火灾后负荷: * / window.addEventListener(加载,FireTimer,假); 如果(document.readyState ==完成){     FireTimer(); } 通过很乖AJAX加载// ---抓住新的页面。 window.addEventListener(hashchange,FireTimer,假); 功能FireTimer(zParam){     的console.log(火:zParam);     的console.log(DATE());     的setTimeout(GotoNextURL,5000); // 5000 ==5秒 } 传播GotoNextURL(){     VAR numUrls = urlsToLoad.length;     VAR urlIdx = urlsToLoad.indexOf(location.href);     urlIdx ++;     如果(urlIdx&GT; = numUrls)         urlIdx = 0;     的console.log(加载,urlsToLoad [urlIdx]);     location.assign(urlsToLoad [urlIdx]); }

I've got a Greasemonkey script (written by another coder - Brock Adams) that loads sequentially the pages contained in the array at the beginning of the code. How to open a list of pages automatically and sequentially?

   // ==UserScript==
// @name        Multipage, MultiSite slideshow of sorts
// @include     http://google.com/*
// @include     http://site2/*
// @include     http://site3/*
// @include     http://site4/*
// @grant       GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a major design
    change introduced in GM 1.0.
    It restores the sandbox.
*/

var urlsToLoad  = [
    'http://google.com/'
    , 'http://site2/somepage/'
    , 'http://site3/somepage/'
    , 'http://site4/somepage/'
];

/*--- Since many of these sites load large pictures, Chrome's and 
    Firefox's injection may fire a good deal before the image(s) 
    finish loading.
    So, insure script fires after load:
*/
window.addEventListener ("load", FireTimer, false);
if (document.readyState == "complete") {
    FireTimer ();
}
//--- Catch new pages loaded by WELL BEHAVED ajax.
window.addEventListener ("hashchange", FireTimer,  false);

function FireTimer () {
    setTimeout (GotoNextURL, 5000); // 5000 == 5 seconds
}

function GotoNextURL () {
    var numUrls     = urlsToLoad.length;
    var urlIdx      = urlsToLoad.indexOf (location.href);
    urlIdx++;
    if (urlIdx >= numUrls)
        urlIdx = 0;

    location.href   = urlsToLoad[urlIdx];
}

The problem comes when I have 2 pages of the same website to be loaded sequentially: the script stops working because the website uses AJAX in order to have a faster loading of its pages.

How can I force this script to fully reload pages?

As you can see he already tried:

//--- Catch new pages loaded by WELL BEHAVED ajax. 
window.addEventListener ("hashchange", FireTimer,  false);

to solve this issue, but it doesn't work as expected.

In particular the site that gives me this issue is ink361.com. I've created a jsFiddle of an example of his source: http://jsfiddle.net/XjjfK/

Thanks in advance.

解决方案

I can't login, but the script worked perfectly for me.
I installed the script exactly as below, and it cycled between those 3 ink361.com pages, just as expected.

Some things for you to do/check:

  1. Are you using your other script (or ANY other GM script) on the same pages?

  2. When you are browsing ink361.com, what does the Greasemonkey menu show?

  3. It sounds like the installed script doesn't have the hashchange code -- which should work on that site, since it does update the hashtags.

    1. Uninstall the script.
    2. Restart Firefox.
    3. Reinstall the script.

  4. Post the exact, unedited script - that you are using - at pastebin.com, and link to it here.

  5. Uninstall any other script for ink361.com, and install just the script below.
    Does it work?
    If not, post the console log, or Firebug's log, at pastebin.com.

// ==UserScript==
// @name        _del me
// @namespace   _pc
// @include     http://ink361.com/*
// @grant       GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a major design
    change introduced in GM 1.0.
    It restores the sandbox.
*/
console.log ("Start: ", Date ());

var urlsToLoad  = [
    'http://ink361.com/#/users/206053596/photos'
    , 'http://ink361.com/#/users/199101377/photos'
    , 'http://ink361.com/#/users/203767882/photos'
];

/*--- Since many of these sites load large pictures, Chrome's and
    Firefox's injection may fire a good deal before the image(s)
    finish loading.
    So, insure script fires after load:
*/
window.addEventListener ("load", FireTimer, false);
if (document.readyState == "complete") {
    FireTimer ();
}
//--- Catch new pages loaded by WELL BEHAVED ajax.
window.addEventListener ("hashchange", FireTimer,  false);

function FireTimer (zParam) {
    console.log ("Fire: ", zParam);
    console.log (Date ());
    setTimeout (GotoNextURL, 5000); // 5000 == 5 seconds
}

function GotoNextURL () {
    var numUrls     = urlsToLoad.length;
    var urlIdx      = urlsToLoad.indexOf (location.href);
    urlIdx++;
    if (urlIdx >= numUrls)
        urlIdx = 0;

    console.log ("Loading: ", urlsToLoad[urlIdx]);
    location.assign (urlsToLoad[urlIdx]);
}

这篇关于如何使页面真正重装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆