aspx页面弹出窗口代码大全

aspx页⾯弹出窗⼝代码⼤全
//关闭,⽗窗⼝弹出对话框,⼦窗⼝直接关闭
this.Response.Write("<script language=javascript>window.close();</script>");
//关闭,⽗窗⼝和⼦窗⼝都不弹出对话框,直接关闭
this.Response.Write("<script>");
this.Response.Write("{top.opener =null;top.close();}");
this.Response.Write("</script>");
//弹出窗⼝刷新当前页⾯width=200 height=200菜单。菜单栏,⼯具条,地址栏,状态栏全没有
this.Response.Write("<script language=javascript>window.open('rows.aspx','newwindow','width=200,height=200')</script>");
//弹出窗⼝刷新当前页⾯
this.Response.Write("<script language=javascript>window.open('rows.aspx')</script>");
this.Response.Write("<script>window.open('WebForm2.aspx','_blank');</script>");
//弹出提⽰窗⼝跳到webform2.aspx页(在⼀个IE窗⼝中)
this.Response.Write(" <script language=javascript>alert('注册成功');window.window.location.href='WebForm2.aspx';</script> ");
//关闭当前⼦窗⼝,刷新⽗窗⼝
捕虾机电路图
this.Response.Write("<script>window.opener.location.href=window.opener.location.href;window.close();</script>");
this.Response.Write("<script>window.place(window.ferrer);window.close();</script>");
//⼦窗⼝刷新⽗窗⼝
this.Response.Write("<script>window.opener.location.href=window.opener.location.href;</script>");
this.Response.Write("<script>window.opener.location.href='WebForm1.aspx';</script>");
//弹出提⽰窗⼝.确定后弹出⼦窗⼝(WebForm2.aspx)
this.Response.Write("<script language='javascript'>alert('发表成功!');window.open('WebForm2.aspx')</script>");
//弹出提⽰窗⼝,确定后,刷新⽗窗⼝
this.Response.Write("<script>alert('发表成功!');window.opener.location.href=window.opener.location.href;</script>");
//弹出相同的⼀页
<INPUT type="button" value="Button" onclick="javascript:window.open(window.location.href)">
//
Response.Write("parent.mainFrameBottom.location.href='yourwebform.aspx?temp=" +str+"';");
<SCRIPT LANGUAGE="javascript">
<!--
window.open ('page.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no') //这句要写成⼀⾏
-->
</SCRIPT>   
  参数解释:
<SCRIPT LANGUAGE="javascript"> js脚本开始;
石墨转子  window.open 弹出新窗⼝的命令;
  'page.html' 弹出窗⼝的⽂件名;
  'newwindow' 弹出窗⼝的名字(不是⽂件名),⾮必须,可⽤空''代替;
  height=100 窗⼝⾼度;
  width=400 窗⼝宽度;
  top=0 窗⼝距离屏幕上⽅的象素值;
  left=0 窗⼝距离屏幕左侧的象素值;
  toolbar=no 是否显⽰⼯具栏,yes为显⽰;
  menubar,scrollbars 表⽰菜单栏和滚动栏。
  resizable=no 是否允许改变窗⼝⼤⼩,yes为允许;
  location=no 是否显⽰地址栏,yes为允许;
  status=no 是否显⽰状态栏内的信息(通常是⽂件已经打开),yes为允许;
  </SCRIPT> js脚本结束
'newwin':隐藏菜单栏地址栏⼯具条
width=50:宽度
height=50:⾼度
scrollbars=yes/no:滚动条
top=50:窗⼝距离屏幕上⽅
left=50:窗⼝距离屏幕左侧
例:window.open('detail.aspx?ID="+e.Item.Cells[1].Text+"','newwin','width=750,height=600,scrollbars=yes,top=50,left=50');");
this.Response.Write("
<Script>window.open('WebForm2.aspx','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=750,height=470,left=80,top=40'); </script>");[/quote]例:
this.Response.Write("<script>alert('发表成功!');window.opener.location.href=window.opener.location.href;</script>");
this.Response.Write("<script>");
this.Response.Write("{top.opener =null;top.close();}");
this.Response.Write("</script>");
例: linkcolumn1.DataNavigateUrlFormatString="javascript:varwin=window.open('edit_usr.aspx?actid=
{0}','newwin','width=750,height=600,scrollbars=yes,top=50,left=50');window.close()";
this.Response.Write("
<Script>window.open('WebForm7.aspx','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=750,height=470,left=80,top=40'); </script>");
弹出跟你当前的窗⼝有没有菜单⼯具栏没有关系,你只要在页⾯中写⼀个脚本它就弹出了.⽐如
<a href=# onclick="window.open('xxx.aspx','窗⼝名称','参数');">xxxxx</a>
以下列出⼀些弹出窗⼝的参数,你可⾃⾏设定,参数之间⽤逗号分隔
可选。字符串--列出对象表并⽤逗号分开。每⼀项都有⾃⼰的值,他们将被分开(如:"fullscreen=yes, toolbar=yes")。下⾯是被⽀持的各种特性。
channelmode = { yes | no | 1 | 0 } 是否在窗⼝中显⽰阶梯模式。默认为no。
directories = { yes | no | 1 | 0 } 是否在窗⼝中显⽰各种按钮。默认为yes。
fullscreen = { yes | no | 1 | 0 } 是否⽤全屏⽅式显⽰浏览器。默认为no。使⽤这⼀特性时需要⾮常⼩⼼。因为这⼀属性可能会隐藏浏览器的标题栏和菜单,你必须提供⼀个按钮或者其他提⽰来帮助使⽤者关闭这⼀浏览窗⼝。ALT+F4可以关闭窗⼝。⼀个全屏窗⼝必须使⽤阶梯(channelmode)模式。
height = number 指定窗⼝的⾼度,单位是像素。最⼩值是100。
left = number 指定窗⼝距左边框的距离,单位是像素。值必须⼤于或者等于0。
location = { yes | no | 1 | 0 } 指定是否在窗⼝中显⽰地址栏。默认为yes。
menubar = { yes | no | 1 | 0 } 指定是否在窗⼝中显⽰菜单栏。默认为yes。
resizable = { yes | no | 1 | 0 } 指定是否在窗⼝中显⽰可供⽤户调整⼤⼩的句柄。默认为yes。
scrollbars = { yes | no | 1 | 0 } 指定是否在窗⼝中显⽰横向或者纵向滚动条。默认为yes。
status = { yes | no | 1 | 0 } 指定是否在窗⼝中显⽰状态栏。默认为yes。
titlebar = { yes | no | 1 | 0 } 指定是否在窗⼝中显⽰标题栏。在⾮调⽤HTML Application或者⼀个对话
框的情况下,这⼀项将被忽略。默认为yes。
toolbar = { yes | no | 1 | 0 } 指定是否在窗⼝中显⽰⼯具栏,包括如前进、后退、停⽌等按钮。默认为yes。
top = number 指定窗⼝顶部的位置,单位是像素。值必须⼤于或者等于0。
width = number 指定窗⼝的宽度,单位是像素。最⼩值是100。
【1、最基本的弹出窗⼝代码】
<SCRIPT LANGUAGE="javascript">
  <!--
  window.open ('page.html')
  -->
  </SCRIPT>
    因为这是⼀段javascripts代码,所以它们应该放在之间。是对⼀些版本低的浏览器起作⽤,在这些⽼浏览器中不会将标签中的代码作为⽂本显⽰出来。要养成这个好习惯啊。window.open ('page.html') ⽤于控制弹出新的窗⼝page.html,如果page.html不与主窗⼝在同⼀路径下,前⾯应写明路径,绝对路径()和相对路径(../)均可。⽤单引号和双引号都可以,只是不要混⽤。这⼀段代码可以加⼊HTML的任意位置,和之间可以,间也可以,越前越早执⾏,尤其是页⾯代码长,⼜想使页⾯早点弹出就尽量往前放。
【2、经过设置后的弹出窗⼝】
  下⾯再说⼀说弹出窗⼝的设置。只要再往上⾯的代码中加⼀点东西就可以了。我们来定制这个弹出的窗⼝的外观,尺⼨⼤⼩,弹出的位置以适应该页⾯的具体情况。 
 <SCRIPT LANGUAGE="javascript">
  <!--
  window.open ('page.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no') //这句要写成⼀⾏
  -->
  </SCRIPT>   
  参数解释:
<SCRIPT LANGUAGE="javascript"> js脚本开始;
  window.open 弹出新窗⼝的命令;
  'page.html' 弹出窗⼝的⽂件名;
  'newwindow' 弹出窗⼝的名字(不是⽂件名),⾮必须,可⽤空''代替;
  height=100 窗⼝⾼度;
pgd-426  width=400 窗⼝宽度;
  top=0 窗⼝距离屏幕上⽅的象素值;
  left=0 窗⼝距离屏幕左侧的象素值;
  toolbar=no 是否显⽰⼯具栏,yes为显⽰;
  menubar,scrollbars 表⽰菜单栏和滚动栏。
  resizable=no 是否允许改变窗⼝⼤⼩,yes为允许;
  location=no 是否显⽰地址栏,yes为允许;
  status=no 是否显⽰状态栏内的信息(通常是⽂件已经打开),yes为允许;
  </SCRIPT> js脚本结束 
智能公交管理系统【3、⽤函数控制弹出窗⼝】
  下⾯是⼀个完整的代码。
<html>
  <head>
  <script LANGUAGE="JavaScript">
  <!--
  function openwin() {
  window.open ("page.html", "newwindow", "height=100, width=400, toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no") //写成⼀⾏
  }
  //-->
  </script>
  </head>
  <body onload="openwin()">
  任意的页⾯内容...
  </body>
  </html>
  这⾥定义了⼀个函数openwin(),函数内容就是打开⼀个窗⼝。在调⽤它之前没有任何⽤途。怎么调⽤呢?
  ⽅法⼀:
<body onload="openwin()"> 浏览器读页⾯时弹出窗⼝;
  ⽅法⼆:
22cccc<body onunload="openwin()"> 浏览器离开页⾯时弹出窗⼝;
  ⽅法三:⽤⼀个连接调⽤:
<a href="#" onclick="openwin()">打开⼀个窗⼝</a>   注意:使⽤的“#”是虚连接。
  ⽅法四:⽤⼀个按钮调⽤:
<input type="button" onclick="openwin()" value="打开窗⼝">
【4、同时弹出2个窗⼝】
  对源代码稍微改动⼀下:
<script LANGUAGE="JavaScript">
  <!--
  function openwin() {
  window.open ("page.html", "newwindow", "height=100, width=100, top=0, left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=n o, status=no")//写成⼀⾏
  window.open ("page2.html", "newwindow2", "height=100, width=100, top=1 00, left=100,toolbar=no, menubar=no, scrollbars=no, resizable=no, loca tion=no,
status=no")//写成⼀⾏
  }
  //-->
  </script> 
为避免弹出的2个窗⼝覆盖,⽤top和left控制⼀下弹出的位置不要相互覆盖即可。最后⽤上⾯说过的四
种⽅法调⽤即可。
  注意:2个窗⼝的name(newwindows和newwindow2)不要相同,或者⼲脆全部为空。
【5、主窗⼝打开⽂件1.htm,同时弹出⼩窗⼝page.html】
  如下代码加⼊主窗⼝区:
<script language="javascript">
  <!--
  function openwin() {
  window.open("page.html","","width=200,height=200")
  }
  //-->
  </script>
  加⼊<body>区:
  <a href="1.htm" onclick="openwin()">open</a>即可。
【6、弹出的窗⼝之定时关闭控制】
  下⾯我们再对弹出的窗⼝进⾏⼀些控制,效果就更好了。如果我们再将⼀⼩段代码加⼊弹出的页⾯(注意是加⼊page.html的HTML中,不是主页⾯中),让它10秒后⾃动关闭是不是更酷了?
⾸先,将如下代码加⼊page.html⽂件的区:
<script language="JavaScript">
  function closeit()
  {
  setTimeout("self.close()",10000) //毫秒
  }
  </script>   然后,再⽤这⼀句话代替page.html中原有的这⼀句就可以了。(这⼀句话千万不要忘记写啊!这⼀句的作⽤是调⽤关闭窗⼝的代码,10秒钟后就⾃⾏关闭该窗⼝。)
【7、在弹出窗⼝中加上⼀个关闭按钮】
<FORM>
  <INPUT TYPE='BUTTON' VALUE='关闭' onClick='window.close()'>
  </FORM>   呵呵,现在更加完美了!
【8、内包含的弹出窗⼝-⼀个页⾯两个窗⼝】
  上⾯的例⼦都包含两个窗⼝,⼀个是主窗⼝,另⼀个是弹出的⼩窗⼝。通过下⾯的例⼦,你可以在⼀个页⾯内完成上⾯的效果。
 <html>
  <head>
  <SCRIPT LANGUAGE="JavaScript">
  function openwin()
  {
  OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no ,scrollbars="+scroll+",menubar=no");
  //写成⼀⾏
  OpenWindow.document.write("<TITLE>例⼦</TITLE>")
  OpenWindow.document.write("<BODY BGCOLOR=#ffffff>")
  OpenWindow.document.write("<h1>Hello!</h1>")
  OpenWindow.document.write("New window opened!")
  OpenWindow.document.write("</BODY>")
  OpenWindow.document.write("</HTML>")
  OpenWindow.document.close()
  }
  </SCRIPT>
  </head>
  <body>
  <a href="#" onclick="openwin()">打开⼀个窗⼝</a>
  <input type="button" onclick="openwin()" value="打开窗⼝">
  </body>
  </html>   看看OpenWindow.document.write()⾥⾯的代码不就是标准的HTML吗?只要按照格式写更多的⾏即可。千万注意多⼀个标签或少⼀个标签就会出现错误。记得⽤ OpenWindow.document.close()结束啊。
【9、终极应⽤--弹出的窗⼝之Cookie控制】
  回想⼀下,上⾯的弹出窗⼝虽然酷,但是有⼀点⼩⽑病,⽐如你将上⾯的脚本放在⼀个需要频繁经
过的页⾯⾥(例如⾸页),那么每次刷新这个页⾯,窗⼝都会弹出⼀次,我们使⽤cookie来控制⼀下就可以了。
  ⾸先,将如下代码加⼊主页⾯HTML的区:
<script>
  function openwin(){
  window.open("page.html","","width=200,height=200")
  }
  function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (kie.length > 0) {
  offset = kie.indexOf(search)
  if (offset != -1) {
  offset += search.length
  end = kie.indexOf(";", offset);
  if (end == -1)
  end = kie.length;
  returnvalue=kie.substring(offset, end))
  }
  }
  return returnvalue;
  } 
  function loadpopup(){虚拟课堂
  if (get_cookie('popped')==''){
  openwin()
  kie="popped=yes"
  }
  }
  </script>   然后,⽤
<body onload="loadpopup()">(注意不是openwin⽽是loadpop啊!)替换主页⾯中原有的这⼀句即可。你可以试着刷新⼀下这个页⾯或重新进⼊该页⾯,窗⼝再也不会弹出了。

本文发布于:2024-09-23 19:19:17,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/2/163478.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:弹出   代码   浏览器   是否   默认   标签   关闭
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议