1.最简单的

<script type="text/javascript">
<!--
window.open("http://cn.bing.com");
window.open("../../page.html");
window.open("some.html");
window.open("some.html","some_tag","height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
-->
</script>

2.使用函数

<script type="text/javascript">
function open_window(){
window.open("some.html");
}
</script>

调用:

1.<body onload="open_window()">    //打开网页弹出
2.<body onunload="open_window()"> //关闭网页弹出
3.<a href="#" onclick="open_window()"> //点击链接弹出

3.让弹出的窗口自动关闭

<script type="text/javascript>
function close_itself(){
setTimeout("self.close()", 10000); //10秒后关闭
}
</script>

4.在当前窗口内弹出

<script type="text/javascript">
OpenWindow=window.open("", "some_tag", "height=250,width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
OpenWindow.document.write("<TITLE>some_example</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>

5.弹出窗口之Cookie控制

<script type="text/javascript">
function open_window(){
window.open("some.html","some_tag","width=200,height=200");
}
function get_cookie(Name){
var search = Name + "=";
var returnvalue = "";
if (documents.cookie.length > 0) {
offset = documents.cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = documents.cookie.indexOf(";", offset);
if (end == -1){
   end = documents.cookie.length;
}
returnvalue=(documents.cookie.substring(offset, end));
}
}
return returnvalue;
}
function loadpopup(){
  if (get_cookie('popped')==''){
    open_window();
    documents.cookie="popped=yes";
  }
}
</script>

6.弹出窗口渐变大

1. 居中弹出窗口, 并逐步扩大
<script type="text/javascript">
if (navigator.appName=="Microsoft Internet Explorer") {//最大化窗口
self.moveTo(-5,-5);
self.resizeTo(screen.availWidth +8,screen.availHeight+8) //这个脚本定义的宽度其实比原窗口还要大那么一点.
}
var w=h=200;
x=(screen.width-w)/2;
y=(screen.height-h)/2;
var n=open('','newWin','width='+w+',height='+h+',left='+x+',right='+x+',top='+y+',bottom='+y);
n.document.write('
<script>
document.write("temp"); /* 临时内容, 去掉出错 */
document.body.innerHTML=""; /* 清空页面内容 */
document.onclick=function() /* 单击关闭窗口 */
</script>');
n.document.write('<h2>test moving window</h2>');
n.focus();
var timer=setInterval('fMovingWin()',1);
function fMovingWin(){
if (n.closed||(w>=screen.width+8&&h>=screen.height+8)) {
clearInterval(timer);
return;
}
try{
if(w<=screen.width+8)w+=2;
if(h<=screen.height+8)h+=2;
n.resizeTo(w, h)
x=(screen.width-w)/2;
y=(screen.height-h)/2;
n.moveTo(x,y)
} catch(e) {} //shawl.qiu script
}
</script>

end

HTML弹出窗口的更多相关文章

  1. jQuery弹出窗口浏览图片

    效果预览:http://keleyi.com/keleyi/phtml/jqtexiao/3.htm HTML文件代码: <!DOCTYPE HTML> <html> < ...

  2. EasyUI弹出窗口实例

    效果体验:http://hovertree.com/texiao/jeasyui/1.htm 源代码下载:HovertreeJEasyUI HTML文件代码: <!DOCTYPE html> ...

  3. 让IE8在win7下面能显示使用window.showmodaldialog弹出窗口的地址状态栏

    问题来源:最近又要对老的系统进行改善,由于用到了window.showmodaldialog这个方法弹出窗口,比如从主界面弹出新增或者修改窗口,如下图所示,显示没有地址栏,进行代码修改还要找到相应的文 ...

  4. java selenium (十二) 操作弹出窗口

    selenium 中如何处理弹出窗口 阅读目录 原理 在代码里, 通过         Set<String> allWindowsId = driver.getWindowHandles ...

  5. JSP弹出窗口和模式对话框

    本文转载于其它blog,在此向本文原创者,致意!    JSP 弹出窗口  一.window.open() 基础知识      1.window.open()支持环境:  JavaScript1.0+ ...

  6. [转]js来弹出窗口的详细说明

    1.警告对话框 <script> alert("警告文字") </script> 2.确认对话框 <script> confirm(" ...

  7. OAF_开发系列08_实现OAF通过Popup参数式弹出窗口(案例)

    20150711 Created By BaoXinjian

  8. 【CefSharp】 禁用右键菜单 与 控制弹出窗口的方式(限版本39.0.0.1)

    这周没什么时间,一开始就在忙一些CefSharp的事情,Win10的研究就放了下来,CefSharp的资料挺少的,但好在是开源的,可以我们便宜的折腾.因为两个的内容都不多,我就合成一篇文章啦. 这还里 ...

  9. jquery-通过js编写弹出窗口

    本文转载 本文主要是通过js动态控制div的高度,css控制浮动 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional// ...

  10. 在HTML网页中设置弹出窗口的办法

    [1.最基本的弹出窗口代码] 其实代码非常简单: <SCRIPT LANGUAGE="javascript"> <!-- window.open ('page.h ...

随机推荐

  1. Intent的4种传值方法总结

    xml 代码: <Button     android:id="@+id/button1"     android:layout_width="wrap_conte ...

  2. HTML5桌面通知(Web Notifications)实例解析

    先上一段代码,ie不支持,Chrome.fireFox.Opera支持 <!DOCTYPE html> <html> <head> <meta http-eq ...

  3. Java关键字介绍之this与super

    1.什么是super?什么是this? super关键字表示超(父)类的意思.this变量代表对象本身. 2.使用super&this调用成员变量和方法 可以使用super访问父类被子类隐藏的 ...

  4. VIew中的触摸事件 touchBegin 等一系列方法

    5.触摸事件  touchBegin 等一系列方法 1)手指按下 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; 2 ...

  5. Xcode6 模拟器不显示键盘

    在学习加法计算器时,程序运行后发现点击模拟器上的输入框时有时候键盘可以弹出来,有时候又弹不出来. 网上查询结果只需要在模拟器的菜单中找到hardware -> keyboard -> 取消 ...

  6. Floyd最短路径算法

    看完这篇文章写的小程序,Floyd最短路径算法,求从一个点到另一个点的最短距离,中间可以经过其他任意个点.三个for循环,从i到j依次经过k的最短距离,最外层for循环是经过点K,内部两个循环是从i( ...

  7. 20150222—LINQ to SQL 插入、更新和删除

    注意,使用LINQ to SQL时, 表中必须有一个主键才可以起效,否则系统将无法对数据作出修改 插入新数据,根据上一片的文章实例在其中添加新的控件: 编号TextBox(Name):sno 名字Te ...

  8. css笔记——关于css中写上charset “utf-8”

    当css文件中写上 charset "utf-8" 时需要将body和html的样式分开写 例如: html,body{margin:0;padding:0;font-family ...

  9. [zz] Install VSFTP

    The first two letters of vsftpd stand for "very secure" and the program was built to have ...

  10. unity 3消 游戏

    3消游戏跟着智能手机流行到现在已经有很长一段时间,unity实现的3消 https://github.com/textcube/match3action 截图如下: 在阅读源码的时候不难发现,Game ...