century
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
隨筆-3 評(píng)論-26 文章-41 trackbacks-0
ShowModalDialog方法的參數(shù)傳遞
利用vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures]),我們可以打開一個(gè)模態(tài)窗口,該窗口的優(yōu)點(diǎn)是限制用戶只能對(duì)當(dāng)前的頁面進(jìn)行操作,而對(duì)其父頁面不能進(jìn)行操作,常用于向?qū)Щ蛘咝畔@取頁面。
利用其中的vArguments我們可以在父頁面和彈出的頁面中進(jìn)行參數(shù)的傳遞,參數(shù)可以為自定義的對(duì)象,也可以傳遞父頁面中任何一個(gè)控件的引用,這使得我們可以很容易的來操作父頁面中的各個(gè)元素,使得參數(shù)的傳遞變得非常容易。
1. 自定義對(duì)象參數(shù)傳遞
我們可以定義一個(gè)javascript對(duì)象,然后定義各種自定義屬性的值,然后可以將此對(duì)象傳遞到子頁面中。
如:父頁面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
>
上述的代碼可以將父頁面的信息封裝成一個(gè)對(duì)象,然后將該對(duì)象傳遞給子頁面。
2.父頁面元素傳遞
以將父頁面中元素對(duì)象的引用傳遞給子頁面,通過該引用我們可以訪問父頁面中的該元素對(duì)象。
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源代碼:
//其中利用元素對(duì)象的引用我們可以操縱父頁面的元素對(duì)象的屬性。
<
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
百年
閱讀(597)
評(píng)論(0)
編輯
收藏
所屬分類:
Javascript Article
新用戶注冊(cè)
刷新評(píng)論列表
只有注冊(cè)用戶
登錄
后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
單擊放回上頁的按鈕或使用window.history.go(-1)返回上頁的同時(shí)刷新"上頁"技術(shù)
js 提交表單
ShowModalDialog方法的參數(shù)傳遞
js獲取URL中的參數(shù)值
計(jì)算中英文混合字符串長度js函數(shù)
window.open和window.showModalDialog的用法詳細(xì)說明
常用于表單JS驗(yàn)證
IE與FireFox下用程序觸發(fā)鼠標(biāo)點(diǎn)擊事件不同的實(shí)現(xiàn)
Javascript中LenB的計(jì)算(ASP)
Javascript 實(shí)現(xiàn)的排序
<
2025年7月
>
日
一
二
三
四
五
六
29
30
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
31
1
2
3
4
5
6
7
8
9
常用鏈接
我的隨筆
我的評(píng)論
我的參與
最新評(píng)論
留言簿
(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)
相冊(cè)
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中用動(dòng)態(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 腳本編寫器
搜索
最新評(píng)論
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(344)
2.?為了學(xué)英語,轉(zhuǎn)載功夫熊貓一篇(280)
3.?什么是軟件外包?(260)
評(píng)論排行榜
1.?為了學(xué)英語,轉(zhuǎn)載功夫熊貓一篇(0)
2.?SP-service provider(0)
3.?什么是軟件外包?(0)
Powered by:
博客園
模板提供:
滬江博客
Copyright ©2025 百年
主站蜘蛛池模板:
洪泽县
|
乐安县
|
泗洪县
|
铜梁县
|
犍为县
|
新建县
|
红河县
|
杂多县
|
汶川县
|
航空
|
肥乡县
|
泗水县
|
凌云县
|
邵阳县
|
临高县
|
郁南县
|
班玛县
|
雅安市
|
汝城县
|
安徽省
|
黄浦区
|
垣曲县
|
游戏
|
尼玛县
|
安乡县
|
赣榆县
|
麻江县
|
宁城县
|
双江
|
沛县
|
云阳县
|
大化
|
连云港市
|
剑川县
|
新疆
|
嘉鱼县
|
泽普县
|
伊春市
|
德兴市
|
天长市
|
宝应县
|