我有一個打開的網頁對話框。從那裏,我想要做的是當用戶點擊一個鏈接時,用修改後的查詢字符串參數刷新對話框的內容。我遇到的問題是,不是用新參數刷新相同的網頁,而是彈出一個新的瀏覽器窗口。防止網頁對話框產生新的瀏覽器窗口?
這裏是用來打開對話框中的頁面:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
function ShowPopup() {
var popWinFeatures = "dialogWidth: 800px;dialogHeight:600px;center:yes;status:no;scroll:no;resizable:yes;help:no";
window.showModalDialog("webPageDialog.html","PopUpWin",popWinFeatures);
}
</script>
</head>
<body>
<a href="#" id="openWebPageDialog" onclick="ShowPopup()">Click For Modal</a>
</body>
</html>
,這是一種試圖刷新與改變的查詢字符串參數的網頁的網頁對話框中的代碼:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="scripts/jquery-1.6.4.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var queryString = "?ab=123";
var newURL = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;
$('#testLink').attr('href', newURL+queryString);
});
</script>
</head>
<body>
<a href="#" onclick="" id="testLink" target="_self">Please Click Me</a>
</body>
</html>
我我也嘗試使用window.open
以及設置window.location
。我也嘗試設置window.location.href
,但結果是一樣的。
新的瀏覽器窗口顯示了我所期望的。它只是不在同一個窗口中。
想法?