将弹出窗口URL替换为相同的URL [英] replacing a popup window URL with the same URL

查看:172
本文介绍了将弹出窗口URL替换为相同的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将myWindow = window.open弹出窗口URL替换为相同的URL,但不确定如何做.我相信我应该使用setTimeout,但是我不确定如何或在哪里放置它.这是我正在使用的编码...

I am needing to replace a myWindow=window.open popup window URL with the same URL but not sure how to. I believe I should use setTimeout but I am not sure how or where to put it. This is the coding I am using...

<script>
function open_win() 
{ 
  myWindow=window.open("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 Collector","width=800px,height=800px");
 }
</script>

与...有关.

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

这个想法是在一个新窗口中打开小书签,成功完成,然后使用setTimeout或另一段代码用与以前相同的小书签替换窗口URL.我尝试了几种不同的方法,但到目前为止没有任何效果.如果有人可以帮助我,我将不胜感激.

The idea is to open the bookmarklet in a new window, which is done successfully, then use setTimeout or another piece of code to replace the window URL with the same bookmarklet as before. I have tried a few different methods but so far nothing has worked. If anyone could help me with this I would greatly appreciate it.

P.S我知道这不是小书签的人用,但据我了解,这是使用小书签的一种可能方法.

P.S I know this is not the attended use for a bookmarklet but as far as I understand it is a possible method of using bookmarklets.

推荐答案

您可以使用任何location方法,例如

You can use any of location methods, for example

var myWindow=window.open("http://www.google.com");

setTimeout(function () { myWindow.location.href = "http://www.google.com" }, 1000)

这是有效的,而myWindow.location.href = myWindow.location.hrefmyWindow.location.reload()如果是跨域调用会导致权限被拒绝"

This works while myWindow.location.href = myWindow.location.href or myWindow.location.reload() would cause "Permission denied" if it's a cross-domain call

这篇关于将弹出窗口URL替换为相同的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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