在父窗口中打开 URL

发布于 2024-12-01 16:03:25 字数 3104 浏览 1 评论 0原文

重新加载页面后,我尝试在父窗口中打开 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: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&#8482; </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">&nbsp;</p>
      <form id="login_sign_fm" name="login_sign_fm" method="post" action="">
</form>      <p class="login_hdr_text_hd2">&nbsp;</p></td>
  </tr>
</table>
</body>
</html>

I am attempting to open a URL in a parent window once a page is reloaded. Currently, it is just reloading the parent window. How do I get it to reload a URL instead of the parent page?

Here is the code:

EDIT: Here is the complete code.

<!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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

给不了的爱 2024-12-08 16:03:26

我遇到了同样的问题,想要从弹出窗口打开父窗口上的特定 URL,而无需重新加载页面。因为我的是 php,所以我不想在重新加载页面时收到警报,因此再次打开它会起作用,因为加载时结果会自行刷新。

我使用以下代码(在子窗口上)来执行此操作:

window.opener.location = "https://www.whateverURLYouWant.com/";

这将在父窗口上加载您想要的任何 URL。

我希望这对未来同样的问题有所帮助。

I had the same problem, wanting to open a specific URL on a parent window from a popup without having to reload the page. Since mine is a php I didn't want to have the alert when reloading the page so opening it again will work as the results will refresh themselves when loading.

I used the following code (on the child window) to do so:

window.opener.location = "https://www.whateverURLYouWant.com/";

This will load whatever URL you want on your parent window.

I hope this help future same questions.

梦开始←不甜 2024-12-08 16:03:26

也许尝试 .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');">

Maybe try .replace(url) instead of .reload(). And while you're at it, you might want to create a simple function for this.

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');">
黄昏下泛黄的笔记 2024-12-08 16:03:26

很简单,只需输入以下内容:

self.opener.location.replace(url,"_self");
alwaysLowered = true; // Bring the Parent window in front & hide the current one

这将在父窗口中打开 url。

告诉我如果它不起作用。

It's Simple Just Put The Following:

self.opener.location.replace(url,"_self");
alwaysLowered = true; // Bring the Parent window in front & hide the current one

This will open url in the parent window.

Tell me if it didn't work.

烟若柳尘 2024-12-08 16:03:25

如果您希望它加载特定的 URL,请设置该 URL,不要调用 reload()。

window.parent.parent.window.location = "http://whatever.com/index.html";

If you want it to load a specific URL, set that URL, don't call reload().

window.parent.parent.window.location = "http://whatever.com/index.html";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文