Javascript 在父窗口中打开URL
我试图在重新加载页面后在父窗口中打开URL。目前,它只是重新加载父窗口。如何让它重新加载URL而不是父页面 代码如下: 编辑:这是完整的代码Javascript 在父窗口中打开URL,javascript,url,window,reload,Javascript,Url,Window,Reload,我试图在重新加载页面后在父窗口中打开URL。目前,它只是重新加载父窗口。如何让它重新加载URL而不是父页面 代码如下: 编辑:这是完整的代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
.left_border_right_cell {
border-left-width: 1px;
border-left-style: solid;
border-left-color: #999;
}
.facebook_login_hd1 {
font-family: Verdana;
font-size: 14pt;
color: #333;
text-decoration: none;
margin-left: 15px;
}
.facebook_body_txt {
font-family: Verdana;
font-size: 12px;
font-weight: normal;
color: #333;
text-decoration: none;
margin-left: 15px;
}
.login_hdr_text_hd2 {
font-family: Verdana;
font-size: 14pt;
color: #900;
text-decoration: none;
margin-left: 15px;
}
.submit_button {
font-family: Verdana;
font-size: 12px;
color: #FFF;
text-decoration: none;
background-color: #900;
border: 1px solid #900;
margin-left: 15px;
}
.facebook_f12media_bld {
font-family: Verdana;
font-size: 12px;
font-weight: bold;
color: #900;
text-decoration: none;
}
.field_properties {
font-family: Verdana;
font-size: 12px;
font-weight: normal;
color: #900;
text-decoration: none;
border: 1px solid #900;
}
.reset_button {
font-family: Verdana;
font-size: 12px;
color: #900;
text-decoration: none;
background-color: #FFF;
border: 1px solid #900;
}
.login_field_label {
font-family: Verdana;
font-size: 12px;
color: #333;
text-decoration: none;
margin-left: 15px;
}
.login_forgot_password {
font-family: Verdana;
font-size: 10px;
font-weight: normal;
color: #900;
text-decoration: none;
margin-left: 15px;
margin-top: 1px;
margin-bottom: 1px;
padding: 0px;
}
</style>
<script language="text/javascript">
function close_reload()
{
parent.parent.window.location.reload();parent.parent.GB_hide();
}
</script>
</head>
<body onload="setTimeout('parent.parent.window.location.replace('http://www.f12media.com/account.php');parent.parent.GB_hide();', 5000)" onunload="parent.parent.window.location.reload();parent.parent.GB_hide();">
<table width="683" height="298" border="0">
<tr>
<td height="312" valign="top"><p class="facebook_login_hd1">Welcome to F12 MEDIA™ </p>
<p class="facebook_body_txt">You are now connected with <span class="facebook_f12media_bld">F12 MEDIA</span>.</p>
</p>
<p class="login_hdr_text_hd2"> </p>
<form id="login_sign_fm" name="login_sign_fm" method="post" action="">
</form> <p class="login_hdr_text_hd2"> </p></td>
</tr>
</table>
</body>
</html>
.左边框右单元格{
左边框宽度:1px;
左边框样式:实心;
左边框颜色:#999;
}
.facebook\u登录\u hd1{
字体系列:Verdana;
字号:14pt;
颜色:#333;
文字装饰:无;
左边距:15px;
}
.facebook\u body\u txt{
字体系列:Verdana;
字体大小:12px;
字体大小:正常;
颜色:#333;
文字装饰:无;
左边距:15px;
}
.login\u hdr\u text\u hd2{
字体系列:Verdana;
字号:14pt;
颜色:#900;
文字装饰:无;
左边距:15px;
}
.提交按钮{
字体系列:Verdana;
字体大小:12px;
颜色:#FFF;
文字装饰:无;
背景色:#900;
边框:1px实心#900;
左边距:15px;
}
.facebook\u f12媒体\u bld{
字体系列:Verdana;
字体大小:12px;
字体大小:粗体;
颜色:#900;
文字装饰:无;
}
.field_属性{
字体系列:Verdana;
字体大小:12px;
字体大小:正常;
颜色:#900;
文字装饰:无;
边框:1px实心#900;
}
.重置按钮{
字体系列:Verdana;
字体大小:12px;
颜色:#900;
文字装饰:无;
背景色:#FFF;
边框:1px实心#900;
}
.登录\字段\标签{
字体系列:Verdana;
字体大小:12px;
颜色:#333;
文字装饰:无;
左边距:15px;
}
.登录\u忘记\u密码{
字体系列:Verdana;
字体大小:10px;
字体大小:正常;
颜色:#900;
文字装饰:无;
左边距:15px;
页边顶部:1px;
边缘底部:1px;
填充:0px;
}
函数close_reload()
{
parent.parent.window.location.reload();parent.parent.GB_hide();
}
欢迎来到F12媒体™
您现在已连接F12媒体
如果希望它加载特定的URL,请设置该URL,不要调用reload()
可能尝试.replace(url)
而不是.reload()
。当你在做的时候,你可能想为它创建一个简单的函数
function loadParent(url) {
parent.parent.window.location.replace(url);
parent.parent.GB_hide();
}
<body onload="setTimeout('loadParent(\"http://cnn.com\")', 5000)"
onunload="loadParent('http://cnn.com');">
函数加载父对象(url){
parent.parent.window.location.replace(url);
parent.parent.GB_hide();
}
很简单,只需输入以下内容:
self.opener.location.replace(url,"_self");
alwaysLowered = true; // Bring the Parent window in front & hide the current one
这将在父窗口中打开url
如果它不起作用,请告诉我。我也遇到了同样的问题,我想从弹出窗口打开父窗口上的特定URL,而不必重新加载页面。由于我的是一个php,我不想在重新加载页面时发出警报,因此再次打开页面会起作用,因为加载时结果会自动刷新 我使用以下代码(在子窗口上)执行此操作:
window.opener.location = "https://www.whateverURLYouWant.com/";
这将在父窗口上加载您想要的任何URL
我希望这有助于今后提出同样的问题。我可能没有提到此页面是在灰盒弹出窗口中打开的。您是否尝试了
parent.window
(而不是parent.parent.window
)?您的代码工作正常,但它不会自动关闭窗口,因为我希望它能像以前那样工作。如何在设定的时间后自动关闭窗口?
window.opener.location = "https://www.whateverURLYouWant.com/";