JavaScript如何打开新窗口然后更改其URL? winRef=新对象(); winRef.closed=true;

JavaScript如何打开新窗口然后更改其URL? winRef=新对象(); winRef.closed=true;,javascript,url,location,Javascript,Url,Location,此代码在新窗口中打开google,然后检查它是否打开并关闭。如何将其名称更改为“” 我需要将我的网站url放在打开的windows url前面以下是代码: <script language=JavaScript> winRef = new Object(); winRef.closed = true; </script> <form name=f1 id=f1> <input type=button name=b1 id=b1 value="New w

此代码在新窗口中打开google,然后检查它是否打开并关闭。如何将其名称更改为“” 我需要将我的网站url放在打开的windows url前面

以下是代码:

<script language=JavaScript>
winRef = new Object();
winRef.closed = true;
</script>

<form name=f1 id=f1>
<input type=button name=b1 id=b1 value="New window" 
onClick="winRef=window.open('http://www.google.com/','myNewWindow',
  'left=15,top=15,width=510,height=420,toolbar=1,menubar=1,resizable=1,status=1');
  winRef.focus()">

<input type=button name=b2 id=b2 value="Close the window" 
onClick="if(!winRef.closed)winRef.close();">

<input type=button name=b3 id=b3 value="Check: is it closed?" 
onClick="alert(winRef.closed ? 'It\'s CLOSED!':'It\'s still OPEN!');">

<input type=button name=b4 id=b4 value="Change new window URL" 
onClick="winRef.location.href('http://example.com/' + winRef.location.href)">
</form>

var strWindowFeatures=“menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=200,height=200”;
var nome='nameofme';
函数vamos(url1){
win=window.open(url1、nome、strWindowFeatures);
win.focus();
//如果窗口成功打开(例如:未被阻止)
如果(赢){
win.onload=function(){//onload可被浏览器阻止
win.location.href=http://www.bing.com';
};
}
setTimeout(“win.location.href=”http://www.bing.com“,4000);//在4秒后更改href
win.focus();
window.history.replaceState('Object','Title','?http://www.bing.com');
setTimeout(“window.history.replaceState('Object','Title','?http://www.fava.com“)”,4000);//4秒后
}
但是

在这里,请记住,在fiddle中,window.history.replaceState不起作用

href
不是一个很好的函数,但我真正需要的是重定向后的链接,例如:打开后的www.google.com将被重定向到www.google.com.uk,因此我需要页面链接www.example.com/?www.google.com后的最后一个链接。uk@user2443940您需要在新窗口打开后或刚打开时重定向用户?但如何将我的链接与当前链接放在一起?@user2443940代码已更新,当我打开一个带有窗口的新窗口时,请检查它。open()如果用户想要导航,我想允许用户更改URL。我如何做到这一点?
    <script language="javascript">
var strWindowFeatures = "menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=200,height=200";
var nome='nameofme';
 function vamos(url1){
    win = window.open(url1,nome,strWindowFeatures);
    win.focus();
    // If the window opened successfully (e.g: not blocked)
    if (win) {
        win.onload = function() {//onload can be blocked by the brower
            win.location.href='http://www.bing.com';
        };
    }
    setTimeout("win.location.href='http://www.bing.com'",4000);//change the href after 4 second
    win.focus();
    window.history.replaceState('Object', 'Title', '?http://www.bing.com');
    setTimeout("window.history.replaceState('Object', 'Title', '?http://www.fava.com')",4000);//after 4 sec
}
</script>
<button id="dd" onClick="vamos('http://www.google.com')">but</button>