zoukankan      html  css  js  c++  java
  • 1.1 弹出窗口控制

    1打开新窗口显示广告信息

     建两个页面,一个命名index.html和一个new.html页面,在index.html页面的head标签中间输入
     
    <script language="javascript">
    window.open("new.html","new","height=141,width=693,top=10,left=20");
    </script>
    打开index.html则在新窗口弹出另一个new.html页面
     
    常用的window对象方法有:

    open                     打开新窗口并装入给定 URL 的文档。
    close                    关闭当前浏览器窗口或 HTML 应用程序(HTA)。
    alert                      显示包含由应用程序自定义消息的对话框。
    confirm                 显示一个确认对话框,其中包含一个可选的消息和确定取消按钮。
    prompt                 显示一个提示对话框,其中带有一条消息和一个输入框。
    attachEvent         将指定函数绑定到事件,每当该事件在对象上触发时调用该函数。
    setTimeout          经过指定毫秒值后计算一个表达式。
    clearTimeout       取消先前用 setTimeout 方法设置的超时事件。
    setInterval            每经过指定毫秒值后计算一个表达式。
    clearInterval         使用 setInterval 方法取消先前开始的间隔事件。
    moveTo               将窗口左上角的屏幕位置移动到指定的 x 和 y 位置。
    resizeTo              将窗口的大小更改为指定的宽度和高度值。
     
    ----------------------------------
    1 open 打开新窗口
    ----------------------------------
    语法:

    window.open(sURL,sName,sFeatures,bReplace )


    参数:
    (1)sUrl:

    可选项,字符串(String)。指定要被加载的HTML文档的URL地址
    (2)sName:
    可选项,字符串(String)。 指定打开的窗口的名字。这个名字可以用于 form 或 a 对象的 TARGET 属性。此名字也可以使用下列通用名称:
    _media :在浏览器左边的媒体面板内打开。
    _blank :在新窗口中打开 sUrl 。
    _parent:在当前框架的父框架内打开。
    _search:在浏览器左边的搜索面板内打开。
    _self :在当前窗口中打开,覆盖当前文档。
    _top :在所有框架之外的最顶层窗口中打开。


    (3)sFeatures:
    可选项。字符串(String)。 指定窗口装饰样式。
    channelmode={yes|no|} 窗口是否显示为频道模式,默认为no。
    directories={yes|no|} 指定是否显示链接按钮,默认值为yes 。
    fullscreen={yes|no|} 指定是否以全屏方式显示窗口,默认no。
    height = number   设置窗口的高度。最小值为 100 。
    left = number 设置窗口左上角相对于桌面的横坐标(像素px)。
    width = number 设置窗口的宽度。最小值为 100 。
    top = number 设置窗口左上角相对于桌面的纵坐标。
    location = {yes|no|}是否显示浏览器窗口的地址栏,默认yes。
    menubar = {yes|no|} 是否显示浏览器窗口的菜单栏,默认yes。
    resizable = {yes|no|}窗口是否允许被用户改变尺寸,默认yes。
    scrollbars = {yes|no|}窗口是否可以具有滚动条,默认值yes。
    status = {yes|no|}是否显示浏览器窗口的状态栏,默认yes。
    titlebar = {yes|no|}是否显示浏览器窗口的标题栏,默认yes。
    toolbar = {yes|no|}是否显示浏览器窗口的工具条,默认yes 。
    (4)bReplace:可选项。布尔值指定新打开的文档覆盖当前文档。
    返回值:返回对新的window对象的引用。
     
    ----------------------------------
    2 setTimeout 定时器
    ----------------------------------

    <script language="javascript">
    function pp(){
    window.open("new.htm","new","height=190,width=775,top=30,left=30");
    }
    setTimeout("pp()",5000);
    </script>
     
    ----------------------------------
    3 通过按钮创建窗口
    ----------------------------------

    <script>
    function pp(){
    window.open('new.html','','toolbar,menubar,scrollbars,resizable,status,location,directories,copyhistory,height=400,width=500');
    }
    </script>
    <form name="form1" method="post" action="">
      <input type="button" name="Button" value="创建新窗口" onClick="pp()">
    </form>
     
    ----------------------------------
    4 自动关闭的广告窗口
    ----------------------------------
    index.html页面代码
     <script language="javascript">
       window.open("new.html","advertise","width=557,height=176,top=10,left=20");
     </script>
    new.html页面代码
     <body οnlοad="window.setTimeout('window.close()',5000)">
     </body>
     
    ----------------------------------
    控制弹出窗口居中显示
    ----------------------------------

     
    <script language="javascript">
    function manage()
    {
    var hdc=window.open('Login_M.htm','','width=322,height=206');
    width=screen.width;
    height=screen.height;
    hdc.moveTo((width-322)/2,(height-206)/2);
    //moveTo 将窗口左上角的屏幕位置移动到指定的 x 和 y 位置。
    }
    </script>
    <a href="javascript:;" onClick="manage()"></a>
     
    ----------------------------------
    关闭窗口代码
    ----------------------------------
    为弹出的窗口加入关闭按钮
    index.html页面
    <script language="javascript">
    function opendialog()
    {
    var width=screen.width;
    var height=screen.height-24;
    window.showModalDialog("remitance.asp","","dialogWidth="+width+"px;dialogHeight="+height+"px;status=no;help=no;scrollbars=no")
    }
    </script>

     
    <p><a href="#"  onClick="window.open('new.html','','width=450,height=300')">最新服务</a></p>
    <input type="button"  value="关闭"  onClick="window.close();" />
     
    new.html页面
    <p><input name="Button" type="button"  value="关闭" onClick="window.close();"></p>
     
     
     
  • 相关阅读:
    宣化上人:大佛顶首楞严经四种清净明诲浅释(4-5)(转自学佛网:http://www.xuefo.net/nr/article23/230699.html)
    宣化上人:大佛顶首楞严经四种清净明诲浅释(6-7)(转自学佛网:http://www.xuefo.net/nr/article23/230700.html)
    宣化上人: 大佛顶首楞严经四种清净明诲浅释(8-9)(转自学佛网:http://www.xuefo.net/nr/article23/230825.html)
    [我的CVE][CVE-2017-15708]Apache Synapse Remote Code Execution Vulnerability
    Ubuntu bash不记录history方法
    [我的CVE][CVE-2017-15709]Apache ActiveMQ Information Leak
    java.lang.Runtime.exec() Payload Workarounds
    CVE-2017-12149 JBOOS AS 6.X 反序列化漏洞利用
    Apache Continuum 远程命令执行漏洞
    docker 端口映射iptables: No chain/target/match by that name错误解决方法
  • 原文地址:https://www.cnblogs.com/Xuman0927/p/12050860.html
Copyright © 2011-2022 走看看