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. link_mysql的php版

    <?php $str_sql_read="select count(*) as num from userinfo"; $str_sql_del="delete f ...

  2. HTML5_注册表单的自动聚焦与占位文本

    首先看下面要使用HTML自动聚焦和占位文本的示例代码 1: <!DOCTYPE html> 2: <html> 3: <head> 4: <title> ...

  3. jQuery - 中文輸入法與KeyDown/KeyPress事件

    最近專案中引用了Telerik ASP.NET擴充元件AutoComplete輸入欄位,測試時發現偶爾會不聽始喚,輸入文字時無法觸發資料查詢,在Javascript Source Code裡反覆追蹤測 ...

  4. CAS Ticket SSO 登录流程图

  5. 关于Windows® API Code Pack for Microsoft® .NET Framework

    相比之前的操作系统,Window 7(or Vista)提供了很多新特性,我们在应用实现中可以利用这些特性来提升用户体验. 这些特性主要包括以下几个方面: Shell Enhancements Dir ...

  6. CCNA长语

    思科认证网络支持工程师(Cisco Certified Network Associate_CCNA) 专业英文词汇大全 10BaseT-----原始IEEE802.3标准的一部分,1OBaseT是1 ...

  7. C#中调用API

    介绍 API( Application Programming Interface ),我想大家不会陌生,它是我们Windows编程的常客,虽然基于.Net平台的C#有了强大的类库,但是,我们还是不能 ...

  8. 【学习笔记】【C语言】常量

    1. 什么是常量 常量,表示一些固定的数据 2. 常量的分类 1> 整型常量(int) 包括了所有的整数,比如6.27.109.256.-10.0.-289等 2> 浮点型常量(float ...

  9. jQuery鼠标事件

    鼠标事件是在用户移动鼠标光标或者使用任意鼠标键点击时触发的.   (1):click事件:click事件于用户在元素敲击鼠标左键,并在相同元素上松开左键时触发.        $('p').click ...

  10. Facade模式和Mediator模式

    相同的目的:把某种策略施加到另一组对象上. Facade从上面施加策略. 其使用是明显且受限的.当策略涉及范围广泛并且可见时. 约定的关注点.都同意使用Facade而不是隐藏于其下的对象. Media ...