century
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
隨筆-3 評論-26 文章-41 trackbacks-0
ShowModalDialog方法的參數(shù)傳遞
利用vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures]),我們可以打開一個模態(tài)窗口,該窗口的優(yōu)點是限制用戶只能對當(dāng)前的頁面進(jìn)行操作,而對其父頁面不能進(jìn)行操作,常用于向?qū)Щ蛘咝畔@取頁面。
利用其中的vArguments我們可以在父頁面和彈出的頁面中進(jìn)行參數(shù)的傳遞,參數(shù)可以為自定義的對象,也可以傳遞父頁面中任何一個控件的引用,這使得我們可以很容易的來操作父頁面中的各個元素,使得參數(shù)的傳遞變得非常容易。
1. 自定義對象參數(shù)傳遞
我們可以定義一個javascript對象,然后定義各種自定義屬性的值,然后可以將此對象傳遞到子頁面中。
如:父頁面sender.htm源代碼為:
<
html
>
<
script
>
function
show()
{
var
person
=
new
Object();
person.myName
=
myName.value;
person.age
=
age.value;
person.country
=
country.value;
window.showModalDialog(
"
target.htm
"
,person,
""
);
}
</
script
>
<
body
>
<
table
>
<
tr
>
<
td
>
name:
</
td
>
<
td
>
<
input
id
="myName"
></
td
>
</
tr
>
<
tr
>
<
td
>
age:
</
td
>
<
td
>
<
input
id
="age"
></
td
>
</
tr
>
<
tr
>
<
td
>
country:
</
td
>
<
td
>
<
input
id
="country"
></
td
>
</
tr
>
</
table
>
<
br
>
<
input
type
="button"
value
="open"
onclick
="show()"
>
</
body
>
</
html
>
彈出的子頁面target.htm的源代碼為:
<
html
>
<
body
>
<
table
>
<
tr
>
<
td
>
name:
</
td
>
<
td
id
="myName"
>
</
td
>
</
tr
>
<
tr
>
<
td
>
age:
</
td
>
<
td
id
="age"
>
</
td
>
</
tr
>
<
tr
>
<
td
>
country:
</
td
>
<
td
id
="country"
>
</
td
>
</
tr
>
</
table
>
</
body
>
<
script
>
var
person
=
window.dialogArguments;
myName.innerText
=
person.myName;
age.innerText
=
person.age;
country.innerText
=
person.country;
</
script
>
</
html
>
上述的代碼可以將父頁面的信息封裝成一個對象,然后將該對象傳遞給子頁面。
2.父頁面元素傳遞
以將父頁面中元素對象的引用傳遞給子頁面,通過該引用我們可以訪問父頁面中的該元素對象。
Sender.htm源代碼:
<
html
>
<
script
>
function
show()
{
window.showModalDialog(
"
target.htm
"
,infoDiv,
""
);
}
</
script
>
<
body
>
<
div
id
="infoDiv"
>
<
table
id
="infoTable"
>
<
tr
>
<
td
>
name:
</
td
>
<
td
>
<
input
id
="myName"
></
td
>
</
tr
>
<
tr
>
<
td
>
age:
</
td
>
<
td
>
<
input
id
="age"
></
td
>
</
tr
>
<
tr
>
<
td
>
country:
</
td
>
<
td
>
<
input
id
="country"
></
td
>
</
tr
>
</
table
>
</
div
>
<
br
>
<
input
type
="button"
value
="conveyElement"
onclick
="show()"
>
</
body
>
</
html
>
Target.htm源代碼:
//其中利用元素對象的引用我們可以操縱父頁面的元素對象的屬性。
<
html
>
<
body
>
<
div
id
="childDiv"
>
</
div
>
<
script
>
var
infoDiv
=
window.dialogArguments;
</
script
>
<
br
>
<
input
type
="button"
value
="showInnerHtml"
onclick
='childDiv.innerHTML=infoDiv.innerHTML'
>
<
br
>
<
input
type
="button"
value
="changePColor"
onclick
='infoDiv.style.backgroundColor="lightgreen"'
>
</
body
>
</
html
>
posted on 2008-03-14 10:51
百年
閱讀(595)
評論(0)
編輯
收藏
所屬分類:
Javascript Article
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
單擊放回上頁的按鈕或使用window.history.go(-1)返回上頁的同時刷新"上頁"技術(shù)
js 提交表單
ShowModalDialog方法的參數(shù)傳遞
js獲取URL中的參數(shù)值
計算中英文混合字符串長度js函數(shù)
window.open和window.showModalDialog的用法詳細(xì)說明
常用于表單JS驗證
IE與FireFox下用程序觸發(fā)鼠標(biāo)點擊事件不同的實現(xiàn)
Javascript中LenB的計算(ASP)
Javascript 實現(xiàn)的排序
<
2025年6月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(1)
給我留言
查看公開留言
查看私人留言
隨筆檔案
2008年7月 (2)
2006年8月 (1)
文章分類
.net(6)
Asp Article(14)
computer manage(2)
div+css(2)
Flash+XML/XML+Flash
Java Article(2)
Javascript Article(10)
Jsp Article(4)
Others(1)
文章檔案
2008年11月 (1)
2008年9月 (3)
2008年8月 (1)
2008年7月 (1)
2008年6月 (1)
2008年4月 (2)
2008年3月 (2)
2008年1月 (2)
2007年12月 (2)
2007年11月 (6)
2007年10月 (1)
2007年8月 (2)
2007年7月 (1)
2007年4月 (3)
2007年3月 (4)
2006年8月 (2)
2006年7月 (1)
2006年6月 (4)
相冊
My collection
收藏夾
JAVA程序員面試32問
CSS
ASP導(dǎo)出Excel數(shù)據(jù)的四種方法
CSS
Jsp
tomcat set
無憂視窗:51windows
用AspJpeg調(diào)整文字水印透明,生成圖片水印的效果
Draw dynamicdrive
Draw dynamic photo
My photo is very poor,so i must word hard!
Draw Flash
Draw Flash
Fade
Fade Images in photoshop
Flash+XML
Flash+XML
http://www.flashcom.com.cn/bbs/forumdisplay.php?f=3
Jacob
jacob
Search Website
程序員代碼搜索
Krugle - Code Search for Developers
Struts
Struts中用動態(tài)選擇的元素創(chuàng)建復(fù)選框
include some website design...
Studying English
Online Dictionary
Here,it is me study english
Translate on google
study
Text Link
\\Access Sql腳本編寫器!
Access to Sql 腳本編寫器
搜索
最新評論
1.?re: js獲取URL中的參數(shù)值
網(wǎng)址打不開
--趙元春
2.?re: js獲取URL中的參數(shù)值
feafwaefeawfewaef
--afasfas
3.?re: js獲取URL中的參數(shù)值
@afasfas
@afasfas
--afasfas
4.?re: js獲取URL中的參數(shù)值[未登錄]
感謝分享.
--匿名
5.?re: js獲取URL中的參數(shù)值[未登錄]
獲取url中的參數(shù)值
--lee
閱讀排行榜
1.?SP-service provider(341)
2.?為了學(xué)英語,轉(zhuǎn)載功夫熊貓一篇(278)
3.?什么是軟件外包?(258)
評論排行榜
1.?為了學(xué)英語,轉(zhuǎn)載功夫熊貓一篇(0)
2.?SP-service provider(0)
3.?什么是軟件外包?(0)
Powered by:
博客園
模板提供:
滬江博客
Copyright ©2025 百年
主站蜘蛛池模板:
尚义县
|
星座
|
五原县
|
土默特左旗
|
西林县
|
磐安县
|
太谷县
|
海安县
|
略阳县
|
马龙县
|
永宁县
|
得荣县
|
兴义市
|
丰原市
|
德庆县
|
和林格尔县
|
绥中县
|
卢湾区
|
屏南县
|
钟祥市
|
德庆县
|
江安县
|
牟定县
|
若尔盖县
|
陆丰市
|
启东市
|
合阳县
|
镇宁
|
横山县
|
濮阳市
|
盐山县
|
晋宁县
|
兴化市
|
任丘市
|
周至县
|
景谷
|
新宁县
|
梁河县
|
武邑县
|
正阳县
|
龙川县
|