2011-08-25 42 views
2

我嘗試在頁面重新加載後在父窗口中打開URL。目前,它只是重新加載父窗口。我如何獲得它來重新加載一個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> 

回答

7

如果您想要它加載特定的URL,請設置該URL,請勿調用reload()。

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

也許試試.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');"> 
+0

既沒有工作。 : -/ – Kevin

+0

我可能沒有提及此頁面在灰色框彈出窗口中打開。 – Kevin

+0

你剛剛嘗試'parent.window'(而不是'parent.parent.window')嗎? – jessegavin

1

很簡單隻要把以下內容:

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

這將在父窗口中打開鏈接。

告訴我,如果它沒有奏效。

0

我有同樣的問題,想要從彈出窗口打開父窗口上的特定URL而不必重新加載頁面。由於我是一個PHP,我不想在重新加載頁面時有警報,所以再次打開它會起作用,因爲結果會在加載時自行刷新。

我用下面的代碼(子窗口中的),這樣做:

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

這將加載你希望你的父窗口的任何URL。

我希望這可以幫助未來的同樣的問題。

相關問題