window对象的几个方法

来源:互联网 发布:怎么绑定淘宝银行卡 编辑:程序博客网 时间:2024/05/22 01:26

1 window.alert(“要弹出的内容”);  弹出窗口;

2 window.confirm("确认信息"); 弹出确认信息,结果为boolean;

3 window.open("url","窗口名称",“窗口位置和尺寸”);打开新窗口;

4 window.close(); 关闭窗口;

5 window.moveTo(x,y);移动到向,x,y位置;

6 window.resizeTo(x,y);改变窗口为指定大小;

7 screen.availHeight 获得屏幕垂直大小,以像素为单位;

8 screen.availWidth 获得屏幕水平大小,以像素为单位;

9 window.resizeBy(x,y) 放大或缩小了窗口x,y;

10 window.scrollTo(x,y);有滚动条的时候,滚动到x,y位置;

11 window.scrollBy(x,y) 滚动了x,y;

<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title><script type="text/javascript">var v;function cls(){if(window.confirm("close ?")){window.close();}}function op(){ v=window.open("new.jsp","new","width=200;height=150");}function clc(){v.close();}function to1(){window.resizeTo(300,300);}function to2(){window.resizeTo(300,300);window.moveTo(300,300);}var x=screen.availWidth-300;var y=screen.availHeight-300;var arr=new Array("0,0",x+",0","0,"+y,x+","+y);window.resizeTo(300, 300);var n=0;var timeId;var count=0;function mv(){if(n>arr.length-1){n=0;}a=arr[n].split(",")[0];b=arr[n].split(",")[1];window.moveTo(parseInt(a),parseInt(b));n=n+1;count++;if(count<10){timeId=setTimeout("mv();", 1000);}else{clearTimeout(timeId);}}function ks(){window.resizeBy(200, 300);}function st(){window.scrollTo(900, 1000);}function st1(){window.scrollBy(20, 10);}</script></head><body><input type="button" value="close" onclick="cls();"><input type="button" value="open" onclick="op();"><input type="button" value="clo" onclick="clc();"><input type="button" value="rt" onclick="to1();"><input type="button" value="mt" onclick="to2();"><input type="button" value="自动移动 " onclick="mv();"><input type="button" value="扩张或缩小 " onclick="ks();"><input type="button" value="滚动到 " onclick="st();"><input type="button" value="滚动了 " onclick="st1();"><p>  假期出游,大家还真要费心思好好挑一下    昨天,央视网官方微信发布消息称,国庆期间部分景区将再次出现人山人海的场景,比如北京、厦门、九寨沟等,并列出了国内外7大拥挤地区、五大拥挤古镇、拥挤摄影地等,供你出游参考。据央视网官方微信  五大拥挤古镇  丽江  凤凰  西塘  青岩  乌镇  五大拥挤浪漫城市  香格里拉  三亚  巴厘岛  马尔代夫  鼓浪屿  五大拥挤摄影地  香格里拉  敦煌  额济纳旗  九寨沟  青海湖  编辑:廉昕朦       相关阅读:  ·周园昨挂牌国家4A级景区 南京首条乡村文博旅游线雏形初现 15-09-20   ·花果山景区为员工设“委屈奖” 已有两人获此奖 15-09-19   ·钟山风景区 道路景观提升 15-09-15   ·中山陵、夫子庙、玄武湖风景区十一黄金周将增临时厕所 15-09-12   ·一年“禁涨”,倒逼景区转型 15-09-10   ·江苏物价局:景区调价满3年 1年内也不能涨价 15-09-09   ·我市9家4A级景区承诺“不涨价” 15-09-08   ·无锡25家景区承诺门票不涨价 15-09-08   ·无锡25家景区承诺门票不涨价 没签承诺书的不代表要涨 15-09-08   ·解禁期一到多地景区宣布涨价 南京景点近期都不会涨价 15-09-07 </p></body></html>


12 访问历史窗口:

    history为数组,存储的为url;

    history.back() 后退一页;

    history.forward() 前进一页;

    history.go(n) 跳到第n页,n为正数,前进,n为负数后退;

<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title><script type="text/javascript">function pri(){for(var v in history){document.write(v+"<br>");}}</script></head><body><a href="his1.jsp">his1</a><br><a href="javascript:history.forward();">forward</a><br><a href="javascript:history.go(1);">go(1)</a><br><a href="javascript:history.go(2);">go(2)</a><br><input type="button" value="打印history" onclick="pri();"><h1>first</h1></body></html>


<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><a href="his2.jsp">his2</a><br><a href="javascript:history.go(-1);">go(-1)</a><br><a href="javascript:history.go(1);">go(1)</a><br><a href="javascript:history.forward();">forward</a><br><a href="javascript:history.back();">back</a><br><h1>second</h1></body></html>

<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><a href="javascript:history.back();">back</a><br><a href="javascript:history.go(-2);">go(-2)</a><br><a href="javascript:history.go(-1);">go(-1)</a><br><h1>Three</h1></body></html>

13 window.defaultstatus 设置状态栏信息;

14 var timerId;       timerId=setTimeout("ws();", 2000);延时2秒执行函数ws();

15 clearTimeout(timerId); 在超时事件函数执行前,终止自动执行;

<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title><script type="text/javascript">var timerId;var n=0;function ws() {p1.innerHTML=n;n++;if(n<9){timerId=setTimeout("ws();", 2000);}else{clearTimeout(timerId);}}onload=ws;</script></head><body><p id="p1"></p></body></html>







0 0
原创粉丝点击