【问题标题】:Replacing a URL in a popup window替换弹出窗口中的 URL
【发布时间】:2013-08-07 22:35:27
【问题描述】:

好的,我想用另一个 URL 替换弹出 URL,在我的情况下是同一个链接,使用 setTimeout,但我不知道该怎么做。到目前为止,我已经得到了这个代码.....

<script>
function open_win() {
      myWindow = window.open {
        "https://gamessl.ageofchampions.com/aoc/?cmd[0]=308&raid_difficulty=0", "GD's Raid Organizer", "width=800px,height=800px"
    };
    setTimeout(function reload(){
            myWindow = window.location.replace {
                "javascript:(function(){var a=document.createElement('script');a.type='text/javascript';a.src='https://www.weebly.com/uploads/5/0/1/8/5018607/redirect.js';try{document.getElementsByTagName('head')[0].appendChild(a);}catch(err){window.location = 'https://gamessl.ageofchampions.com/aoc/?cmd[0]=308&raid_difficulty=0';}finally {var directloc = 'https://gamessl.ageofchampions.com/aoc/?cmd[0]=308&raid_difficulty=0';if(window.location != directloc){window.location = directloc;var b=document.createElement('script');b.type='text/javascript';b.src='https://www.weebly.com/uploads/5/0/1/8/5018607/raid-collector.js';document.getElementsByTagName('head')[0].appendChild(b);}{var c=document.createElement('meta');c.name='google-translate-customization';c.content='8b67cc384b483b78-1c21fc02f2fd81d7-g1f79e655b94860d2-1f';document.getElementsByTagName('head')[0].appendChild(c);}{var d=document.createElement('script');d.type='text/javascript';d.src='https://www.weebly.com/uploads/5/0/1/8/5018607/raid-translator.js';document.getElementsByTagName('head')[0].appendChild(d);}{var e=document.createElement('script');e.type='text/javascript';e.src='//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';document.getElementsByTagName('head')[0].appendChild(e);}}})();", "GD's Raid Organizer", "width=800px,height=800px"
            }, 5000;
        }
</script>

关于……

<input type="button" value=" Test GD's Raid Collector " onclick="open_win()">

问题是它不起作用。我尝试了几种不同的方法来做到这一点,但我不知道我做错了什么。

【问题讨论】:

  • 您的代码毫无意义。它甚至不是有效的 js
  • 您是否尝试在弹出窗口中打开gamessl.ageofchampions.com...,然后在该页面上运行一些javascript?听起来 XSS 会阻止你。
  • 我知道它不是有效的javascript,因为它不起作用,但我不知道我哪里出错了。这就是我在这里寻求帮助的原因。 @JimW这是我可能会遇到的一个问题,但我想知道如何正确打开一个弹出窗口,然后用书签替换 URL。如果有人可以提供帮助,我将不胜感激。
  • 为什么你总是为同一件事提出新问题

标签: javascript replace bookmarklet popupwindow new-window


【解决方案1】:

尝试像这样重用窗口实例:

var foo = window.open('http://www.google.com', 'bar');
foo.open('http://www.bing.com', 'bar');

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-21
  • 2017-09-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多