js 點擊按鈕彈出另一頁,選擇值后,返回到當前頁
更新時間:2010年05月26日 21:56:01 作者:
js 點擊按鈕彈出另一頁,選擇值后,返回到當前頁,其實主要用于cms系統(tǒng)中,相關(guān)文章的搜索,要在已上傳目錄中選擇一些圖片等。
1。 效果圖:

2。 主頁面的代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function open_windows_and_get_selectedinfo(openwindow, control, control2) {
var str = window.showModalDialog(openwindow, window, "dialogWidth=740px;dialogHeight=600px;center=yes;help=no;resizable=no;status=no");
if (!str)
return;
document.getElementById(control).value = str[0];
document.getElementById(control2).value = str[1];
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="autosuggest" style="width:160px;font-size:12px;"><ul></ul></div>
<div>
<input id="txtActive" runat="server" readonly="readonly" />
<input type="button" id="selectActive" runat="server" onclick="javascript:open_windows_and_get_selectedinfo('TestEdt.aspx','hfActive','txtActive')" value="..." />
<asp:HiddenField ID="hfActive" runat="server" />
</div>
</form>
</body>
</html>
3。 彈出頁面的代碼:
<html xmlns="http://www.w3.org/1999/xhtml">
<base target="_self">
<head runat="server">
<title></title>
<script type="text/javascript" language="javascript">
function dbclick_return_and_close(strid, strvalue) {
alert("執(zhí)行該方法!");
var str = new Array(strid, strvalue);
window.returnValue = str;
window.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="#" onclick="javascript:dbclick_return_and_close( '1', 'aaaaaaa');">點擊這一行,帶值返回到原頁面</a>
</div>
</form>
</body>
</html>

2。 主頁面的代碼:
復制代碼 代碼如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function open_windows_and_get_selectedinfo(openwindow, control, control2) {
var str = window.showModalDialog(openwindow, window, "dialogWidth=740px;dialogHeight=600px;center=yes;help=no;resizable=no;status=no");
if (!str)
return;
document.getElementById(control).value = str[0];
document.getElementById(control2).value = str[1];
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="autosuggest" style="width:160px;font-size:12px;"><ul></ul></div>
<div>
<input id="txtActive" runat="server" readonly="readonly" />
<input type="button" id="selectActive" runat="server" onclick="javascript:open_windows_and_get_selectedinfo('TestEdt.aspx','hfActive','txtActive')" value="..." />
<asp:HiddenField ID="hfActive" runat="server" />
</div>
</form>
</body>
</html>
3。 彈出頁面的代碼:
復制代碼 代碼如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<base target="_self">
<head runat="server">
<title></title>
<script type="text/javascript" language="javascript">
function dbclick_return_and_close(strid, strvalue) {
alert("執(zhí)行該方法!");
var str = new Array(strid, strvalue);
window.returnValue = str;
window.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="#" onclick="javascript:dbclick_return_and_close( '1', 'aaaaaaa');">點擊這一行,帶值返回到原頁面</a>
</div>
</form>
</body>
</html>
相關(guān)文章
JavaScript常見事件處理程序?qū)嵗偨Y(jié)
這篇文章主要介紹了JavaScript常見事件處理程序,結(jié)合實例形式總結(jié)分析了javascript HTML事件、DOM事件、IE事件等相關(guān)處理程序與操作技巧,需要的朋友可以參考下2019-01-01B/S開發(fā)中常用javaScript技術(shù)與代碼
B/S開發(fā)中常用javaScript技術(shù)與代碼...2007-03-03JavaScript學習筆記之取值函數(shù)getter與取值函數(shù)setter詳解
這篇文章主要介紹了JavaScript取值函數(shù)getter與取值函數(shù)setter,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-08-08