两层或以上的showModalDialog解决方法
生活随笔
收集整理的這篇文章主要介紹了
两层或以上的showModalDialog解决方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在網頁制作中經常會碰到數據的新增、修改、刪除和查詢等基本的功能,如果新增和修改功能是用? IE中的? showModalDialog 彈出對話框來實現新增數據和修改數據功能,新增或修改數據成功返回后則刷新其父頁面。但showModalDialog有時候可能會帶來一些你不想發生的結果,比如有關一些緩存、刷新,可能也會導致排版的一些問題(說錯莫怪,或指正);前些日子,項目中碰到的就是刷新的問題:
1、當頁面為普通的頁面時或者應該稱為非showModalDialog調用時,進行調用showModalDialog彈出對話框來新增修改數據一切正常;
2、當頁面為showModalDialog調用時,再進行調用showModalDialog彈出對話框來新增修改數據或做其它的一些事情,此時刷新就出現了一些問題。
3、也就是說當有兩層或兩以上的showModalDialog時,刷新就會出現問題了(它們另彈出一個頁面)。
解決思路:
1、在<head></head>中加入<base target="_self" />,測試一樣的效果??鄲瀒ng.....
2、通過javascript動態更改網頁的地址,什么window.location.href = "url";或window.navigate("url")都不行。
3、baidu了一下查不到什么的解決方法,無奈中~~~,聽說showModalDialog中沒有location,不知道是不是?
4、看看鏈接可不可以解決此問題,加入<a href="url" >url</a> 測試一下,咦行得通,哈,那以上的問題也就解決了一大半了。
以下為一些代碼:
文件:071214Test ShowModalDialg Step One.htm
?1?<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01//EN"?"http://www.w3.org/TR/html4/strict.dtd">
?2?<html>
?3?????<head>????????
?4?????????<meta?http-equiv="Content-Type"?content="text/html;?charset=gb2312"?/>
?5?????????<meta?name="keywords"?content="showModalDialog,彈出對話框,Dialog">????????
?6?????????<meta?name="Author"?Content="Sam?Lin,林森桐,linsentong@126.com">
?7?????????<meta?name="Contact"?content="linsentong@126.com"?/>
?8?????????<META?content="showModalDialog?--?Sam?Lin,彈出對話框解決方法,三層showModalDialog解決方法"?name="description">
?9?????????<META?content="MSHTML?6.00.2900.3199"?name=GENERATOR>
10?????????<META?content=TRUE?name=MSSmartTagsPreventParsing>
11?????????<META?http-equiv=MSThemeCompatible?content=Yes>
12?????????<title>Test?ShowModalDialg?Step?One</title>
13?????????<base?target="_self"?/>
14?????????<script?type="text/javascript"?src=DialogUtil.js></script>
15?????????<style?type="text/css">
16?????????????html,body
17?????????????{
18?????????????????background:#DCDCDC;????????????????
19?????????????}
20?????????????.Description,input
21?????????????{
22?????????????????border:1px?#6595d6?dashed;
23?????????????????padding:5px;
24?????????????????margin:0?auto;
25?????????????????color:#000;
26?????????????????font-size:12px;????????????????????????
27?????????????}
28?????????????a
29?????????????{
30?????????????????text-decoration:none;????
31?????????????}
32?????????????a:link{color:#4682B4}
33?????????????a:visited{color:#4682B4}
34?????????????a:hover{color:#F4A460}
35?????????????a:active{color:#F4A460}
36?????????????.title
37?????????????{
38?????????????????background:#BDB76B;
39?????????????????line-height:24px;
40?????????????????text-align:left;
41?????????????????font-size:16px;
42?????????????????padding:2px;
43?????????????????font-weight:bold;
44?????????????????text-indent:12px;
45?????????????????color:#4682B4;
46?????????????}
47?????????????
48?????????</style>
49?????</head>
50?????<body>
51?????<div?class="Description">
52?????<div?class="title">
53?????????說明
54?????</div>
55?????????Author:Sam?Lin<br?/>
56?????????Contact:<a?href="mailto:linsentong@126.com">linsentong@126.com</a><br?/>
57?????????Memo:解決多層彈出對話框出現的問題,合適IE瀏覽器。<br?/>
58?????????Date:Dec.14,2007
59?????????<br?/>
60?????????<br?/>
61?????????第一層
62?????</div>
63?????<br?/>
64?????<input?type="button"?value="彈出第二層對話框"?onclick="ShowNewOrEditDialog({
65?????????????????????????????????????????????????????????????????????????Url:'071214Test?ShowModalDialg?Step?Two.htm',
66?????????????????????????????????????????????????????????????????????????Width:500,Height:400})">
67?????</body>
68?</html>
69?
文件二:071214Test ShowModalDialg Step Two.htm
?1?<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01//EN"?"http://www.w3.org/TR/html4/strict.dtd">
?2?<html>
?3?????<head>
?4?????????<meta?http-equiv="Content-Type"?content="text/html;?charset=gb2312"?/>
?5?????????<meta?name="keywords"?content="showModalDialog,彈出對話框,Dialog">
?6?????????<meta?name="Author"?Content="Sam?Lin,林森桐,linsentong@126.com">
?7?????????<meta?name="Contact"?content="linsentong@126.com"?/>
?8?????????<META?content="showModalDialog?--?Sam?Lin,彈出對話框解決方法,三層showModalDialog解決方法"?name="description">
?9?????????<META?content="MSHTML?6.00.2900.3199"?name=GENERATOR>
10?????????<META?content=TRUE?name=MSSmartTagsPreventParsing>
11?????????<META?http-equiv=MSThemeCompatible?content=Yes>
12?????????<title>Test?ShowModalDialg?Step?Two</title>????????
13?????????<script?type="text/javascript"?src=DialogUtil.js></script>
14?????????<style?type="text/css">
15?????????????html,body
16?????????????{
17?????????????????background:#DCDCDC;????????????????
18?????????????}
19?????????????.Description,input
20?????????????{
21?????????????????border:1px?#6595d6?dashed;
22?????????????????padding:5px;
23?????????????????margin:0?auto;
24?????????????????color:#000;
25?????????????????font-size:12px;????????????????????????
26?????????????}
27?????????????a
28?????????????{
29?????????????????text-decoration:none;????
30?????????????}
31?????????????a:link{color:#4682B4}
32?????????????a:visited{color:#4682B4}
33?????????????a:hover{color:#F4A460}
34?????????????a:active{color:#F4A460}
35?????????????.title
36?????????????{
37?????????????????background:#BDB76B;
38?????????????????line-height:24px;
39?????????????????text-align:left;
40?????????????????font-size:16px;
41?????????????????padding:2px;
42?????????????????font-weight:bold;
43?????????????????text-indent:12px;
44?????????????????color:#4682B4;
45?????????????}
46?????????????
47?????????</style>
48?????????
49?????????<base?target="_self"?/>
50?????</head>
51?????<body?>
52?????<div?class="Description">
53?????<div?class="title">
54?????????說明
55?????</div>
56?????????Author:Sam?Lin<br?/>
57?????????Contact:<a?href="mailto:linsentong@126.com">linsentong@126.com</a><br?/>
58?????????Memo:解決多層彈出對話框出現的問題,合適IE瀏覽器。<br?/>
59?????????Date:Dec.14,2007
60?????????<br?/>
61?????????<br?/>
62?????????第二層
63?????</div>
64?????
65?????<br?/>
66?????<input?type="button"?value="彈出第三層對話框"?onclick="ShowNewOrEditDialog({
67?????????????????????????????????????????????????????????????????????????Url:'071214Test?ShowModalDialg?Step?Three.htm',
68?????????????????????????????????????????????????????????????????????????Width:500,Height:400})">
69?????<a?href="http://www.cnblogs.com/samlin"?id="test"?title="林森桐的blog">My?Blog</a>????
70?????<br?/>
71?????<input?type="button"?value="將頁面地址設為:http://www.baidu.com"?onclick="javascript:window.location.href?=?'http://www.baidu.com';">
72?????<input?type="button"?value="關閉(沒有返回值)"?onclick="javascript:window.close();"?/>
73?????<input?type="button"?value="關閉(有返回值)"?onclick="javascript:window.returnValue?=?true;window.close();"?/>
74?????<br?/>????????????????????????????????????????????????
75?????</body>
76?</html>
77?
文件三:
?1?<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01//EN"?"http://www.w3.org/TR/html4/strict.dtd">
?2?<html>
?3?????<head>
?4?????????<meta?http-equiv="Content-Type"?content="text/html;?charset=gb2312"?/>
?5?????????<meta?name="keywords"?content="showModalDialog,彈出對話框,Dialog">
?6?????????<meta?name="Author"?Content="Sam?Lin,林森桐,linsentong@126.com">
?7?????????<meta?name="Contact"?content="linsentong@126.com"?/>
?8?????????<META?content="showModalDialog?--?Sam?Lin,彈出對話框解決方法,三層showModalDialog解決方法"?name="description">
?9?????????<META?content="MSHTML?6.00.2900.3199"?name=GENERATOR>
10?????????<META?content=TRUE?name=MSSmartTagsPreventParsing>
11?????????<META?http-equiv=MSThemeCompatible?content=Yes>
12?????????<title>071214Test?ShowModalDialg?Step?Three</title>
13?????????<script?type="text/javascript"?src=DialogUtil.js></script>
14?????????<style?type="text/css">
15?????????????html,body
16?????????????{
17?????????????????background:#DCDCDC;????????????????
18?????????????}
19?????????????.Description,input
20?????????????{
21?????????????????border:1px?#6595d6?dashed;
22?????????????????padding:5px;
23?????????????????margin:0?auto;
24?????????????????color:#000;
25?????????????????font-size:12px;????????????????????????
26?????????????}
27?????????????a
28?????????????{
29?????????????????text-decoration:none;????
30?????????????}
31?????????????a:link{color:#4682B4}
32?????????????a:visited{color:#4682B4}
33?????????????a:hover{color:#F4A460}
34?????????????a:active{color:#F4A460}
35?????????????.title
36?????????????{
37?????????????????background:#BDB76B;
38?????????????????line-height:24px;
39?????????????????text-align:left;
40?????????????????font-size:16px;
41?????????????????padding:2px;
42?????????????????font-weight:bold;
43?????????????????text-indent:12px;
44?????????????????color:#4682B4;
45?????????????}
46?????????????
47?????????</style>
48?????????<base?target="_self"?/>
49?????</head>
50?????<body?onbeforeunload="javascript:window.returnValue=true;">
51?????<div?class="Description">
52?????<div?class="title">
53?????????說明
54?????</div>
55?????????Author:Sam?Lin<br?/>
56?????????Contact:<a?href="mailto:linsentong@126.com">linsentong@126.com</a><br?/>
57?????????Memo:解決多層彈出對話框出現的問題,合適IE瀏覽器。<br?/>
58?????????Date:Dec.14,2007
59?????????<br?/>
60?????????<br?/>
61?????????第三層
62?????</div>
63?????</body>
64?</html>
65?
JS文件:DialogUtil.js
/**//**
?*?@author?Sam?Lin
?*?@email:?linsentong@126.com
?*?Date:Dec.16,2007
?*?Memo:This?function?only?for?IE?browser
?*/
function?ShowNewOrEditDialog(/**//*object?hash*/info)
{
????var?strOriginalUrl?=?document.location.href;
????var?strHrefID?=?"ReloadUrlHref";
????//strHrefID?=?"test";
????var?objHref?=?null;
????var?strTargetUrl?=?info.Url;
????var?iWidth?=?info.Width;????????/**//*the?web?page?arguments?e.g?width,height,left?etc.*/
????var?iHeight?=?info.Height;
????var?iLeft?=?screen.availWidth;
????var?iTop?=?screen.availHeight;
????iLeft?=?(iLeft?-?iWidth)?/?2;
????iTop?=?(iTop?-?iHeight)?/?2;
????var?strArgs?=?"left:"?+?iLeft?+?";top:"?+?iTop?+?";width:"?+?iWidth?+?";height:"?+?iHeight;
????var?strResult?=?window.showModalDialog(strTargetUrl,'',strArgs);
????//alert(strOriginalUrl);
????/**//*
????if?(typeof?window.location?==?"undefined"?||?typeof?window.location?==?null)
????{
????????alert("Null");
????}
????else
????{
????????alert(window.location.href?+?"?Not?Null");
????????window.location.href?=?"http://www.google.cn";
????}*/
????//window.location.href?=?"http://www.google.cn";
????
????//create?the?href?element?for?reload?function
????
????//?if?true?load?the?page
????//alert(strResult);
????if?(strResult?!=?""?&&?strResult?!=?false?&&?strResult?!=?"undefined"?&&?strResult?!=undefined)
????{
????????if?($(strHrefID))
????????{
????????????objHref?=?$(strHrefID);????
????????}
????????else
????????{
????????????objHref?=?document.createElement("A");
????????????
????????????//objHref.innerText?=?"Link?Me";
????????????//objHref.onclick?=?function(){alert("OnClick")};
????????????document.body.appendChild(objHref);
????????????
????????}????
????????//objHref.href?=?strOriginalUrl;
????????objHref.href?=?"http://www.cnblogs.com/samlin";
????????
????????objHref.onclick?=?function()
????????{
????????????var?oDiv?=?document.createElement("div");
????????????oDiv.style.width?=?"300px";
????????????oDiv.style.height?=?"50px";
????????????oDiv.style.lineHeight?=?"50px";
????????????oDiv.style.position?=?"absolute";
????????????oDiv.style.margin?=?"0?auto";
????????????oDiv.style.padding?=?"2px";
????????????oDiv.style.display?=?"block";
????????????oDiv.style.textAlign?=?"center";
????????????oDiv.style.backgroundColor?=?"#FFEBCD";
????????????oDiv.style.border?=?"1px?dashed?#6595d6";
????????????oDiv.innerText?=?"Loading?another?page?";
????????????//oDiv.style.left?=?(document.body.availWidth?-?300)?+?"px";
????????????document.body.appendChild(oDiv);
????????????
????????};
????????fireClickEvent(strHrefID);
????????objHref.click();????
????}????
}
/**//**
?*?@return?the?object?belongs?to?the?specified?id
?*?@param?{Object}?id
?*/
function?$(id)
{
????return?document.getElementById(id);
}
function?fireClickEvent(id)
{
????var?obj?=?$(id);
????if?(obj)
????{
????????if?(document.all)
????????{
????????????obj.fireEvent("onclick");
????????}
????????else
????????{
????????????var?evt?=?document.createEvent("MouseEvents");
????????????evt.initEvent("click",true,true);
????????????obj.dispatchEvent(evt);
????????????
????????}????????
????}
} 示例代碼:refresh_showModalDialog.rar
1、當頁面為普通的頁面時或者應該稱為非showModalDialog調用時,進行調用showModalDialog彈出對話框來新增修改數據一切正常;
2、當頁面為showModalDialog調用時,再進行調用showModalDialog彈出對話框來新增修改數據或做其它的一些事情,此時刷新就出現了一些問題。
3、也就是說當有兩層或兩以上的showModalDialog時,刷新就會出現問題了(它們另彈出一個頁面)。
解決思路:
1、在<head></head>中加入<base target="_self" />,測試一樣的效果??鄲瀒ng.....
2、通過javascript動態更改網頁的地址,什么window.location.href = "url";或window.navigate("url")都不行。
3、baidu了一下查不到什么的解決方法,無奈中~~~,聽說showModalDialog中沒有location,不知道是不是?
4、看看鏈接可不可以解決此問題,加入<a href="url" >url</a> 測試一下,咦行得通,哈,那以上的問題也就解決了一大半了。
以下為一些代碼:
文件:071214Test ShowModalDialg Step One.htm
?1?<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01//EN"?"http://www.w3.org/TR/html4/strict.dtd">
?2?<html>
?3?????<head>????????
?4?????????<meta?http-equiv="Content-Type"?content="text/html;?charset=gb2312"?/>
?5?????????<meta?name="keywords"?content="showModalDialog,彈出對話框,Dialog">????????
?6?????????<meta?name="Author"?Content="Sam?Lin,林森桐,linsentong@126.com">
?7?????????<meta?name="Contact"?content="linsentong@126.com"?/>
?8?????????<META?content="showModalDialog?--?Sam?Lin,彈出對話框解決方法,三層showModalDialog解決方法"?name="description">
?9?????????<META?content="MSHTML?6.00.2900.3199"?name=GENERATOR>
10?????????<META?content=TRUE?name=MSSmartTagsPreventParsing>
11?????????<META?http-equiv=MSThemeCompatible?content=Yes>
12?????????<title>Test?ShowModalDialg?Step?One</title>
13?????????<base?target="_self"?/>
14?????????<script?type="text/javascript"?src=DialogUtil.js></script>
15?????????<style?type="text/css">
16?????????????html,body
17?????????????{
18?????????????????background:#DCDCDC;????????????????
19?????????????}
20?????????????.Description,input
21?????????????{
22?????????????????border:1px?#6595d6?dashed;
23?????????????????padding:5px;
24?????????????????margin:0?auto;
25?????????????????color:#000;
26?????????????????font-size:12px;????????????????????????
27?????????????}
28?????????????a
29?????????????{
30?????????????????text-decoration:none;????
31?????????????}
32?????????????a:link{color:#4682B4}
33?????????????a:visited{color:#4682B4}
34?????????????a:hover{color:#F4A460}
35?????????????a:active{color:#F4A460}
36?????????????.title
37?????????????{
38?????????????????background:#BDB76B;
39?????????????????line-height:24px;
40?????????????????text-align:left;
41?????????????????font-size:16px;
42?????????????????padding:2px;
43?????????????????font-weight:bold;
44?????????????????text-indent:12px;
45?????????????????color:#4682B4;
46?????????????}
47?????????????
48?????????</style>
49?????</head>
50?????<body>
51?????<div?class="Description">
52?????<div?class="title">
53?????????說明
54?????</div>
55?????????Author:Sam?Lin<br?/>
56?????????Contact:<a?href="mailto:linsentong@126.com">linsentong@126.com</a><br?/>
57?????????Memo:解決多層彈出對話框出現的問題,合適IE瀏覽器。<br?/>
58?????????Date:Dec.14,2007
59?????????<br?/>
60?????????<br?/>
61?????????第一層
62?????</div>
63?????<br?/>
64?????<input?type="button"?value="彈出第二層對話框"?onclick="ShowNewOrEditDialog({
65?????????????????????????????????????????????????????????????????????????Url:'071214Test?ShowModalDialg?Step?Two.htm',
66?????????????????????????????????????????????????????????????????????????Width:500,Height:400})">
67?????</body>
68?</html>
69?
文件二:071214Test ShowModalDialg Step Two.htm
?1?<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01//EN"?"http://www.w3.org/TR/html4/strict.dtd">
?2?<html>
?3?????<head>
?4?????????<meta?http-equiv="Content-Type"?content="text/html;?charset=gb2312"?/>
?5?????????<meta?name="keywords"?content="showModalDialog,彈出對話框,Dialog">
?6?????????<meta?name="Author"?Content="Sam?Lin,林森桐,linsentong@126.com">
?7?????????<meta?name="Contact"?content="linsentong@126.com"?/>
?8?????????<META?content="showModalDialog?--?Sam?Lin,彈出對話框解決方法,三層showModalDialog解決方法"?name="description">
?9?????????<META?content="MSHTML?6.00.2900.3199"?name=GENERATOR>
10?????????<META?content=TRUE?name=MSSmartTagsPreventParsing>
11?????????<META?http-equiv=MSThemeCompatible?content=Yes>
12?????????<title>Test?ShowModalDialg?Step?Two</title>????????
13?????????<script?type="text/javascript"?src=DialogUtil.js></script>
14?????????<style?type="text/css">
15?????????????html,body
16?????????????{
17?????????????????background:#DCDCDC;????????????????
18?????????????}
19?????????????.Description,input
20?????????????{
21?????????????????border:1px?#6595d6?dashed;
22?????????????????padding:5px;
23?????????????????margin:0?auto;
24?????????????????color:#000;
25?????????????????font-size:12px;????????????????????????
26?????????????}
27?????????????a
28?????????????{
29?????????????????text-decoration:none;????
30?????????????}
31?????????????a:link{color:#4682B4}
32?????????????a:visited{color:#4682B4}
33?????????????a:hover{color:#F4A460}
34?????????????a:active{color:#F4A460}
35?????????????.title
36?????????????{
37?????????????????background:#BDB76B;
38?????????????????line-height:24px;
39?????????????????text-align:left;
40?????????????????font-size:16px;
41?????????????????padding:2px;
42?????????????????font-weight:bold;
43?????????????????text-indent:12px;
44?????????????????color:#4682B4;
45?????????????}
46?????????????
47?????????</style>
48?????????
49?????????<base?target="_self"?/>
50?????</head>
51?????<body?>
52?????<div?class="Description">
53?????<div?class="title">
54?????????說明
55?????</div>
56?????????Author:Sam?Lin<br?/>
57?????????Contact:<a?href="mailto:linsentong@126.com">linsentong@126.com</a><br?/>
58?????????Memo:解決多層彈出對話框出現的問題,合適IE瀏覽器。<br?/>
59?????????Date:Dec.14,2007
60?????????<br?/>
61?????????<br?/>
62?????????第二層
63?????</div>
64?????
65?????<br?/>
66?????<input?type="button"?value="彈出第三層對話框"?onclick="ShowNewOrEditDialog({
67?????????????????????????????????????????????????????????????????????????Url:'071214Test?ShowModalDialg?Step?Three.htm',
68?????????????????????????????????????????????????????????????????????????Width:500,Height:400})">
69?????<a?href="http://www.cnblogs.com/samlin"?id="test"?title="林森桐的blog">My?Blog</a>????
70?????<br?/>
71?????<input?type="button"?value="將頁面地址設為:http://www.baidu.com"?onclick="javascript:window.location.href?=?'http://www.baidu.com';">
72?????<input?type="button"?value="關閉(沒有返回值)"?onclick="javascript:window.close();"?/>
73?????<input?type="button"?value="關閉(有返回值)"?onclick="javascript:window.returnValue?=?true;window.close();"?/>
74?????<br?/>????????????????????????????????????????????????
75?????</body>
76?</html>
77?
文件三:
?1?<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01//EN"?"http://www.w3.org/TR/html4/strict.dtd">
?2?<html>
?3?????<head>
?4?????????<meta?http-equiv="Content-Type"?content="text/html;?charset=gb2312"?/>
?5?????????<meta?name="keywords"?content="showModalDialog,彈出對話框,Dialog">
?6?????????<meta?name="Author"?Content="Sam?Lin,林森桐,linsentong@126.com">
?7?????????<meta?name="Contact"?content="linsentong@126.com"?/>
?8?????????<META?content="showModalDialog?--?Sam?Lin,彈出對話框解決方法,三層showModalDialog解決方法"?name="description">
?9?????????<META?content="MSHTML?6.00.2900.3199"?name=GENERATOR>
10?????????<META?content=TRUE?name=MSSmartTagsPreventParsing>
11?????????<META?http-equiv=MSThemeCompatible?content=Yes>
12?????????<title>071214Test?ShowModalDialg?Step?Three</title>
13?????????<script?type="text/javascript"?src=DialogUtil.js></script>
14?????????<style?type="text/css">
15?????????????html,body
16?????????????{
17?????????????????background:#DCDCDC;????????????????
18?????????????}
19?????????????.Description,input
20?????????????{
21?????????????????border:1px?#6595d6?dashed;
22?????????????????padding:5px;
23?????????????????margin:0?auto;
24?????????????????color:#000;
25?????????????????font-size:12px;????????????????????????
26?????????????}
27?????????????a
28?????????????{
29?????????????????text-decoration:none;????
30?????????????}
31?????????????a:link{color:#4682B4}
32?????????????a:visited{color:#4682B4}
33?????????????a:hover{color:#F4A460}
34?????????????a:active{color:#F4A460}
35?????????????.title
36?????????????{
37?????????????????background:#BDB76B;
38?????????????????line-height:24px;
39?????????????????text-align:left;
40?????????????????font-size:16px;
41?????????????????padding:2px;
42?????????????????font-weight:bold;
43?????????????????text-indent:12px;
44?????????????????color:#4682B4;
45?????????????}
46?????????????
47?????????</style>
48?????????<base?target="_self"?/>
49?????</head>
50?????<body?onbeforeunload="javascript:window.returnValue=true;">
51?????<div?class="Description">
52?????<div?class="title">
53?????????說明
54?????</div>
55?????????Author:Sam?Lin<br?/>
56?????????Contact:<a?href="mailto:linsentong@126.com">linsentong@126.com</a><br?/>
57?????????Memo:解決多層彈出對話框出現的問題,合適IE瀏覽器。<br?/>
58?????????Date:Dec.14,2007
59?????????<br?/>
60?????????<br?/>
61?????????第三層
62?????</div>
63?????</body>
64?</html>
65?
JS文件:DialogUtil.js
/**//**
?*?@author?Sam?Lin
?*?@email:?linsentong@126.com
?*?Date:Dec.16,2007
?*?Memo:This?function?only?for?IE?browser
?*/
function?ShowNewOrEditDialog(/**//*object?hash*/info)
{
????var?strOriginalUrl?=?document.location.href;
????var?strHrefID?=?"ReloadUrlHref";
????//strHrefID?=?"test";
????var?objHref?=?null;
????var?strTargetUrl?=?info.Url;
????var?iWidth?=?info.Width;????????/**//*the?web?page?arguments?e.g?width,height,left?etc.*/
????var?iHeight?=?info.Height;
????var?iLeft?=?screen.availWidth;
????var?iTop?=?screen.availHeight;
????iLeft?=?(iLeft?-?iWidth)?/?2;
????iTop?=?(iTop?-?iHeight)?/?2;
????var?strArgs?=?"left:"?+?iLeft?+?";top:"?+?iTop?+?";width:"?+?iWidth?+?";height:"?+?iHeight;
????var?strResult?=?window.showModalDialog(strTargetUrl,'',strArgs);
????//alert(strOriginalUrl);
????/**//*
????if?(typeof?window.location?==?"undefined"?||?typeof?window.location?==?null)
????{
????????alert("Null");
????}
????else
????{
????????alert(window.location.href?+?"?Not?Null");
????????window.location.href?=?"http://www.google.cn";
????}*/
????//window.location.href?=?"http://www.google.cn";
????
????//create?the?href?element?for?reload?function
????
????//?if?true?load?the?page
????//alert(strResult);
????if?(strResult?!=?""?&&?strResult?!=?false?&&?strResult?!=?"undefined"?&&?strResult?!=undefined)
????{
????????if?($(strHrefID))
????????{
????????????objHref?=?$(strHrefID);????
????????}
????????else
????????{
????????????objHref?=?document.createElement("A");
????????????
????????????//objHref.innerText?=?"Link?Me";
????????????//objHref.onclick?=?function(){alert("OnClick")};
????????????document.body.appendChild(objHref);
????????????
????????}????
????????//objHref.href?=?strOriginalUrl;
????????objHref.href?=?"http://www.cnblogs.com/samlin";
????????
????????objHref.onclick?=?function()
????????{
????????????var?oDiv?=?document.createElement("div");
????????????oDiv.style.width?=?"300px";
????????????oDiv.style.height?=?"50px";
????????????oDiv.style.lineHeight?=?"50px";
????????????oDiv.style.position?=?"absolute";
????????????oDiv.style.margin?=?"0?auto";
????????????oDiv.style.padding?=?"2px";
????????????oDiv.style.display?=?"block";
????????????oDiv.style.textAlign?=?"center";
????????????oDiv.style.backgroundColor?=?"#FFEBCD";
????????????oDiv.style.border?=?"1px?dashed?#6595d6";
????????????oDiv.innerText?=?"Loading?another?page?";
????????????//oDiv.style.left?=?(document.body.availWidth?-?300)?+?"px";
????????????document.body.appendChild(oDiv);
????????????
????????};
????????fireClickEvent(strHrefID);
????????objHref.click();????
????}????
}
/**//**
?*?@return?the?object?belongs?to?the?specified?id
?*?@param?{Object}?id
?*/
function?$(id)
{
????return?document.getElementById(id);
}
function?fireClickEvent(id)
{
????var?obj?=?$(id);
????if?(obj)
????{
????????if?(document.all)
????????{
????????????obj.fireEvent("onclick");
????????}
????????else
????????{
????????????var?evt?=?document.createEvent("MouseEvents");
????????????evt.initEvent("click",true,true);
????????????obj.dispatchEvent(evt);
????????????
????????}????????
????}
} 示例代碼:refresh_showModalDialog.rar
總結
以上是生活随笔為你收集整理的两层或以上的showModalDialog解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Velocity的layout功能
- 下一篇: 行冗余