Window.ShowModalDialog使用总结

Window.ShowModalDialog使用手册

基本介绍:

  showModalDialog()                              (IE 4+ 支持)
  showModelessDialog()                         (IE 5+ 支持)
  window.showModalDialog()                 方法用来创建一个显示HTML内容的模态对话框。
  window.showModelessDialog()            方法用来创建一个显示HTML内容的非模态对话框。

  使用方法:

  vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
  vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])

  参数说明:

  sURL             --   必选参数,类型:字符串。用来指定对话框要显示的文档的URL
  vArguments   --    可选参数,类型:变体。用来向对话框传递参数。传递的参数类型不限,包括数组等。对话框通过window.dialogArguments来取得传递进来的参数。
  sFeatures      --    可选参数,类型:字符串。用来描述对话框的外观等信息,可以使用以下的一个或几个,用分号“;”隔开。

----------------
1.   dialogHeight:   对话框高度,不小于100px
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+]:是否显示状态栏。默认为yes[ Modeless]或no[Modal]。
9.   scroll:{ yes | no | 1 | 0 | on | off }:是否显示滚动条。默认为yes。

下面几个属性是用在HTA中的,在一般的网页中一般不使用。

10.   dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者打印预览时对话框是否隐藏。默认为no。
11.   edge:{ sunken | raised }:指明对话框的边框样式。默认为raised。
12.   unadorned:{ yes | no | 1 | 0 | on | off }:默认为no。

  参数传递:

1.要想对话框传递参数,是通过vArguments来进行传递的。类型不限制,对于字符串类型,最大为4096个字符。也可以传递对象,例如

parent.htm

<script>
  var obj = new Object();
  obj.name="51js";
  window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.htm
<script>
  var obj = window.dialogArguments
  alert("您传递的参数为:" + obj.name)
</script>

-------------------------------
2.   可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如:
------------------------------
parent.htm
<script>
         str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");
         alert(str);
</script>
modal.htm
<script>
         window.returnValue="http://www.webjx.com";
</script>

 

工作使用总结:

sUrl:如跳出的对话框公共调用,放在一个文件夹下public,那sUrl="Public/web.aspx".

1.第一个页面

1.1.html代码

 “var num=Math.random();”加个随机行数,让跳出的窗口更新。

// window.location.reload();    '刷新出现错误“新整理网页,必须重新传送资讯”用以下代替,就会解决此问题。
     window.location.href=window.location.href;  

ContractedBlock.gif ExpandedBlockStart.gif Code
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 runat="server">
    
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
// <!CDATA[

function btnShowModalDialog_onclick() {

var V1="Hello,";
var V2="ike_li";
  
var num=Math.random();
  
var sret=window.showModalDialog("Default2.aspx?V1="+V1+"&V2="+V2+"&num="+num,"","dialogHeight: 655px; dialogWidth: 759px; dialogTop: 60px; dialogLeft: 100px; edge: Raised; center: Yes;help:no; resizable: Yes; status: Yes;scroll:no;")
  
if(sret == "refresh"
    {
        window.location.href
=window.location.href;
    }    

}

// ]]>
</script>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
        
<input id="btnShowModalDialog" style="width: 216px" type="button" value="TestShowModalDialog" onclick="return btnShowModalDialog_onclick()" /></div>
    
</form>
</body>
</html>

2.跳出窗口

2.1 html代码

 “<base target="download"/> ,<iframe id="download"  name="download" height="0px" width="0px"></iframe>” 为了防止点击button,处理数据,保持原页面的大小,也可以换成“ <base target="_self" />”,但这个在处理下载文件另存会出现没有反应。

ContractedBlock.gif ExpandedBlockStart.gif Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!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 runat="server">
    
<title>Dialog Page</title>
    
<base target="download"/> 
       
<script language="javascript" type="text/javascript">
// <!CDATA[
function closed()
{
  window.returnValue 
= "refresh";

}
// ]]>
</script>
</head>
<body onunload="closed()">
    
<form id="form1" runat="server">
    
<iframe id="download"  name="download" height="0px" width="0px"></iframe>
    
<div>
        
<asp:Button ID="Button1" runat="server" Height="32px" Text="Button" Width="72px" />
        
<asp:Label ID="lblShow" runat="server" Width="96px"></asp:Label></div>
    
</form>
</body>
</html>

 

2.2后台代码

ContractedBlock.gif ExpandedBlockStart.gif Code
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string str1 = Request.QueryString["V1"];
        string str2 = Request.QueryString["V2"];
        lblShow.Text = str1 + str2;
    }
}

 

 Javascript刷新页面的几种方法:
1   history.go(0)
2   location.reload()
3   location=location
4   location.assign(location)
5   document.execCommand('Refresh')
6   window.navigate(location)
7   location.replace(location)
8   document.URL=location.href

自动刷新页面的方法:
1.页面自动刷新:把如下代码加入<head>区域中
<meta http-equiv="refresh" content="20">
其中20指每隔20秒刷新一次页面.

2.页面自动跳转:把如下代码加入<head>区域中
<meta http-equiv="refresh" content="20;url=http://www.wyxg.com">
其中20指隔20秒后跳转到http://www.wyxg.com页面

3.页面自动刷新js版
<script language="JavaScript">
 function myrefresh()
 {
      window.location.reload();
 }
 setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>

ASP.NET如何输出刷新父窗口脚本语句
1.  this.response.write("<script>opener.location.reload();</script>"); 

2.  this.response.write("<script>opener.window.location.href = opener.window.location.href;</script>");  

3.  Response.Write("<script language=javascript>opener.window.navigate(''你要刷新的页.asp'');</script>")


JS刷新框架的脚本语句

//如何刷新包含该框架的页面用   
<script language=JavaScript>
  parent.location.reload();
</script>  

//子窗口刷新父窗口
<script language=JavaScript>
   self.opener.location.reload();
</script>

( 或 <a href="javascript:opener.location.reload()">刷新</a>   )

//如何刷新另一个框架的页面用   
<script language=JavaScript>
  parent.另一FrameID.location.reload();
</script>

如果想关闭窗口时刷新或者想开窗时刷新的话,在<body>中调用以下语句即可。

<body οnlοad="opener.location.reload()">
开窗时刷新
<body onUnload="opener.location.reload()">
关闭时刷新

<script language="javascript">
window.opener.document.location.reload()
</script>

 

转载于:https://www.cnblogs.com/qfb620/archive/2009/04/22/1440958.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
步科触摸屏的函数脚本说明 目 录 1. KingSCADA的条件事件脚本等系统脚本中不能调用画面内部的对象吗? ...1 2. 我想在一个画面中调用另一个画面的内部对象,怎样做?............................1 3. 画面自定义变量和属性除了能被本画面的图素引用,其他的画面能引用吗? .............................................................................................................................................3 4. 导航图应用有EnableNavigate()和ShowNavigateWindow()两个函数,他们有什 么区别?.............................................................................................................................3 5. KingSCADA 提 供 保 存 画 面 的 函 数 , 如 SavePictureToFile() 、 SaveWholePictureToFile()函数,我写在按钮命令语言里为什么不执行?..................3 6. 利用表格模板和SQLCreateTable()函数创建数据库表格,为什么创建不成 功?.....................................................................................................................................3 7. 用SQLDropTable()函数删除一个数据库表格,为什么删不掉? ....................3 8. 用SQLGetRecord()函数为什么不能返回当前选择集中的指定序号的记录? 3 9. 用VarRefAddress函数不能实现变量的引用?..................................................4 10. KingSCADA运行系统怎样得到当前产生的报警数量? .................................4 11. 怎样从实时报警窗中手动删除确认过的报警记录?......................................5 12. KingSCADA可以实现通过弹出对话框让用户选择文件的功能吗? .............5 13. 有累计计算脚本,长时间运行后,累计值不变?..........................................6 14. FileWriteStr(“c:\sql.txt”,0,“sfd%”,0);但是输出文本里少了%?........................6 15. 在应用程序启动时脚本里添加了打开画面函数,运行时,画面没有打开? .............................................................................................................................................6 16. KS工程里有数据库查询或插入的脚本,长时间运行后,不能查询或插入记 录?.....................................................................................................................................6 17. KingSCADA的全局脚本、局部脚本有大小的限制吗? .................................6 18. KingSCADA中怎样实现把同一类型的文件名显示在列表框中?类似于组态 王的ListLoadFileName()函数的功能。............................................................................6 19. 怎样在KingSCADA运行时获取加密锁序列号? ............................................7 20. 通过调用数据集函数KDBGetDataset()对access数据库进行操作时,一直 报错“对象关闭时,不允许操作。 DBAccess: Open the source recordset failed!”?.7 21. 图素对象属性中的hotkey热键作用?...............................................................7
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值