简体   繁体   English

是否可以使用javascript循环打开一个网站,多次执行一个函数?

[英]Is it possible to use a javascript loop to open a website, excecute a function several times?

I'm trying to make a script where I can access a bunch of links, and excecute the same script on alle websites.我正在尝试制作一个脚本,我可以在其中访问一堆链接,并在所有网站上执行相同的脚本。 I've tried to implement the 'this.document.location = "";'我试图实现 'this.document.location = "";' function, but every it seems like it's not possible to open more than one website each time I run the script.功能,但似乎每次运行脚本时都无法打开多个网站。 Using the setTimeout() function, it would still just open one of the websites.使用 setTimeout() 函数,它仍然只会打开其中一个网站。

If I have an array of strings, how would it be possible to iterate through all the links, until I've executed the script on all the websites?如果我有一个字符串数组,如何遍历所有链接,直到我在所有网站上执行了脚本?

I think you might be locking for an iframe.我认为您可能正在锁定 iframe。 You can run a script from a parent to a child.您可以从父级到子级运行脚本。 your page --- contains ---> iframe ---> another website.您的页面 --- 包含 ---> iframe ---> 另一个网站。

Some websites won't load inside an iframe due to X-Frame-Options and some restrictions also enforce if the website your loading is not part of the same domain.由于X-Frame-Options ,一些网站不会在 iframe 内加载,如果您加载的网站不是同一域的一部分,一些限制也会强制执行。 If part of the same domain, you can execute javascript code.如果属于同一个域,则可以执行javascript代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM