欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript showModalDialog傳值與FireFox的window.open 父子窗口傳值示例第1/2頁

 更新時間:2009年11月08日 22:36:15   作者:  
javascript showModalDialog傳值與FireFox的window.open 父子窗口傳值示例代碼。
先簡單介紹一下基本知識:
一、window.open()支持環(huán)境: Java1.0+/J1.0+/Nav2+/IE3+/Opera3+
二、基本語法:
window.open(pageURL,name,parameters)
其中:
pageURL 為子窗口路徑
name 為子窗口句柄
parameters 為窗口參數(shù)(各參數(shù)用逗號分隔)
三、各項參數(shù)
其中yes/no也可使用1/0;pixel value為具體的數(shù)值,單位象素。
參數(shù) | 取值范圍 | 說明
alwaysLowered | yes/no | 指定窗口隱藏在所有窗口之后
alwaysRaised | yes/no | 指定窗口懸浮在所有窗口之上
depended | yes/no | 是否和父窗口同時關閉
directories | yes/no | Nav2和3的目錄欄是否可見
height | pixel value | 窗口高度
hotkeys | yes/no | 在沒菜單欄的窗口中設安全退出熱鍵
innerHeight | pixel value | 窗口中文檔的像素高度
innerWidth | pixel value | 窗口中文檔的像素寬度
location | yes/no | 位置欄是否可見
menubar | yes/no | 菜單欄是否可見
outerHeight | pixel value | 設定窗口(包括裝飾邊框)的像素高度
outerWidth | pixel value | 設定窗口(包括裝飾邊框)的像素寬度
resizable | yes/no | 窗口大小是否可調整
screenX | pixel value | 窗口距屏幕左邊界的像素長度
screenY | pixel value | 窗口距屏幕上邊界的像素長度
scrollbars | yes/no | 窗口是否可有滾動欄
titlebar | yes/no | 窗口題目欄是否可見
toolbar | yes/no | 窗口工具欄是否可見
Width | pixel value | 窗口的像素寬度
z-look | yes/no | 窗口被激活后是否浮在其它窗口之上
window.showModalDialog使用手冊
基本介紹:
showModalDialog() (IE 4+ 支持)
showModelessDialog() (IE 5+ 支持)
window.showModalDialog()方法用來創(chuàng)建一個顯示HTML內容的模態(tài)對話框。
window.showModelessDialog()方法用來創(chuàng)建一個顯示HTML內容的非模態(tài)對話框。
使用方法:
vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])
參數(shù)說明:
sURL--
必選參數(shù),類型:字符串。用來指定對話框要顯示的文檔的URL。
vArguments--
可選參數(shù),類型:變體。用來向對話框傳遞參數(shù)。傳遞的參數(shù)類型不限,包括數(shù)組等。對話框通過window.dialogArguments來取得傳遞進來的參數(shù)。
sFeatures--
可選參數(shù),類型:字符串。用來描述對話框的外觀等信息,可以使用以下的一個或幾個,用分號“;”隔開。
1.dialogHeight :對話框高度,不小于100px,IE4中dialogHeight 和 dialogWidth 默認的單位是em,而IE5中是px,為方便其見,在定義modal方式的對話框時,用px做單位。
2.dialogWidth: 對話框寬度。
3.dialogLeft: 離屏幕左的距離。
4.dialogTop: 離屏幕上的距離。
5.center: {yes | no | 1 | 0 }:窗口是否居中,默認yes,但仍可以指定高度和寬度。
6.help: {yes | no | 1 | 0 }:是否顯示幫助按鈕,默認yes。
7.resizable: {yes | no | 1 | 0 } [IE5+]:是否可被改變大小。默認no。
8.status: {yes | no | 1 | 0 } [IE5+]:是否顯示狀態(tài)欄。默認為yes[ Modeless]或no[Modal]。
9.scroll:{ yes | no | 1 | 0 | on | off }:指明對話框是否顯示滾動條。默認為yes。
下面幾個屬性是用在HTA中的,在一般的網(wǎng)頁中一般不使用。
10.dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者打印預覽時對話框是否隱藏。默認為no。
11.edge:{ sunken | raised }:指明對話框的邊框樣式。默認為raised。
12.unadorned:{ yes | no | 1 | 0 | on | off }:默認為no。
參數(shù)傳遞:
1.要想對話框傳遞參數(shù),是通過vArguments來進行傳遞的。類型不限制,對于字符串類型,最大為4096個字符。也可以傳遞對象,例如:
-------------------------------
parent.htm
復制代碼 代碼如下:

<script type="text/javascript">
var obj = new Object();
obj.name="51js";
window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>

modal.htm
復制代碼 代碼如下:

<script type="text/javascript">
var obj = window.dialogArguments
alert("您傳遞的參數(shù)為:" + obj.name)
</script>

-------------------------------
2.可以通過window.returnValue向打開對話框的窗口返回信息,當然也可以是對象。例如:
------------------------------
parent.htm
復制代碼 代碼如下:

< type="text/java">
str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");
alert(str);
</script>

modal.htm
復制代碼 代碼如下:

<script type="text/javascript">
window.returnValue="http://www.dbjr.com.cn";
</script>

在IE中,我們可以使用showModalDialog來傳值。
語法如下:
vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
但是.在Firefox中卻沒有showModalDialog方法,不過我們可以用window.open()
語法如下:
oNewWindow = window.open( [sURL] [, sName] [, sFeatures] [, bReplace])
只是,在Firefox下,window.open的參數(shù)中,sFeature多了一些功能設定,而在FireFox下要讓開啟的視窗跟IE的showModalDialog一樣的話,只要在sFeatures中加個modal=yes就可以了。
下面用一個示例來說明其用法。
功能說明:從子窗口中輸入顏色種類提交到父窗口,并添加選項到下拉列表。
a.html
復制代碼 代碼如下:

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>a.html文檔</title>
<script language="javascript">
function openstr()
{
ReturnValue=window.showModalDialog("b.html",window,"dialogWidth=510px;dialogHeight=150px;status=no");
if(ReturnValue && ReturnValue!="")
{
oOption = document.createElement('OPTION');
oOption.text=ReturnValue;
oOption.value=ReturnValue;
document.all.txtselect.add(oOption);
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<select name="txtselect" id="txtselect">
</select>
</label>
<label>
<input type="button" name="Submit" value="打開子窗口" onclick="openstr()" />
</label>
</form>
</body>
</html>

b.html
復制代碼 代碼如下:

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>b.html文檔</title>
<script language="javascript">
function ClickOk()
{
var t=document.Edit;
var url=t.color.value;
if(url==null||url=="填寫顏色") return(false);
window.returnValue=url;
window.close();
}
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="2" align="center" width="300">
<form name="Edit" id="Edit">
<tr>
<td width="30" align="right" height="30">color:</td>
<td height="30"><input type="text" name="color" value="填寫顏色" /></td>
<td width="56" align="center" height="30"><input " type="button" name="bntOk" value="確認" onclick="ClickOk();" /> </td>
</tr>
</form>
</table>
</body>
</html>
修改為兼容IE和FireFoxr的代碼如下:
[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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>a.html文檔</title>
<script type="text/javascript">
function openstr()
{
window.open("b.html","","modal=yes,width=500,height=500,resizable=no,scrollbars=no");
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<select name="txtselect" id="txtselect">
</select>
</label>
<label>
<input type="button" name="Submit" value="打開子窗口" onclick="openstr()" />
</label>
</form>
</body>
</html>

b.html
復制代碼 代碼如下:

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>b.html文檔</title>
<script type="text/javascript">
function ClickOk()
{
var t=document.Edit;
var color=t.color.value;
if(color==null||color=="填寫顏色") return(false);
var oOption = window.opener.document.createElement('OPTION');
oOption.text=url;
oOption.value=url;
//檢查瀏覽器類型
var bname = navigator.appName;
if (bname.search(/netscape/i) == 0)
{
window.opener.document.getElementById("txtselect").appendChild(oOption);
}
else if (bname.search(/microsoft/i) == 0)
{
window.opener.document.all.txtselect.add(oOption);
}
else
{
}
window.close();
}
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="2" align="center" width="300">
<form name="Edit" id="Edit">
<tr>
<td width="30" align="right" height="30">color:</td>
<td height="30"><input type="text" name="color" value="填寫顏色" /></td>
<td width="56" align="center" height="30"><input " type="button" name="bntOk" value="確認" onclick="ClickOk();" /> </td>
</tr>
</form>
</table>
</body>
</html>

相關文章

  • 30分鐘快速實現(xiàn)小程序語音識別功能

    30分鐘快速實現(xiàn)小程序語音識別功能

    最近需要在小程序上實現(xiàn)語音識別,將需要用到的功能都總結下,供大家參考。語音識別用的是科大訊飛,文中給出了詳細的實現(xiàn)方法介紹,需要的朋友們下面隨著小編來一起學習學習吧
    2018-11-11
  • JS實現(xiàn)可移動模態(tài)框

    JS實現(xiàn)可移動模態(tài)框

    這篇文章主要為大家詳細介紹了JS實現(xiàn)可移動模態(tài)框,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • 淺談JavaScript原型鏈

    淺談JavaScript原型鏈

    這篇文章主要為大家詳細介紹了JavaScript原型鏈,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2023-04-04
  • 使用Turn.js實現(xiàn)翻書效果的完整步驟

    使用Turn.js實現(xiàn)翻書效果的完整步驟

    最近項目經(jīng)理我個項目練練手,其項目需求是要實現(xiàn)翻書效果,下面這篇文章主要給大家介紹了關于使用Turn.js實現(xiàn)翻書效果的相關資料,文中通過代碼介紹的非常詳細,需要的朋友可以參考下
    2023-12-12
  • JavaScript表單驗證實現(xiàn)代碼

    JavaScript表單驗證實現(xiàn)代碼

    這篇文章主要為大家詳細介紹了JavaScript表單驗證的實現(xiàn)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • JS變量中有var定義和無var定義的區(qū)別以及es6中l(wèi)et命令和const命令

    JS變量中有var定義和無var定義的區(qū)別以及es6中l(wèi)et命令和const命令

    這篇文章主要介紹了JS變量中有var定義和無var定義的區(qū)別以及es6中l(wèi)et命令和const命令,需要的朋友可以參考下
    2017-02-02
  • 微信小程序--onShareAppMessage分享參數(shù)用處(頁面分享)

    微信小程序--onShareAppMessage分享參數(shù)用處(頁面分享)

    本篇文章主要介紹了微信小程序的頁面分享onShareAppMessage分享參數(shù)用處的相關資料。具有很好的參考價值。下面跟著小編一起來看下吧
    2017-04-04
  • electron 引入node服務的操作方法

    electron 引入node服務的操作方法

    這篇文章主要介紹了electron 引入node服務的操作方法,引入node服務很簡單,直接在electron的主體中引入就可以了,對electron 引入node服務感興趣的朋友一起看看吧
    2024-03-03
  • JS實現(xiàn)頁面跳轉鏈接的幾種方式匯總

    JS實現(xiàn)頁面跳轉鏈接的幾種方式匯總

    這篇文章主要介紹了JS實現(xiàn)頁面跳轉鏈接的幾種方式,簡單總結了幾種頁面跳轉功能的實現(xiàn),有使用js跳轉頁面,返回上一次預覽界面及button按鈕添加事件跳轉,本文結合實例代碼給大家介紹的非常詳細,需要的朋友參考下吧
    2024-01-01
  • ECMAScript6函數(shù)默認參數(shù)

    ECMAScript6函數(shù)默認參數(shù)

    這篇文章主要介紹了ECMAScript6函數(shù)默認參數(shù)的相關資料,需要的朋友可以參考下
    2015-06-06

最新評論