Javascript学习笔录9(窗口属性操作-status、背景色、title等)
来源:互联网 发布:感康和泰诺 知乎 编辑:程序博客网 时间:2024/05/17 23:57
1 改变状态栏
window.status='welcome to my website
2 改变文本颜色
document.bgColor --背景色
document.fgColor -- 字体颜色
3 更改标题
document.title="Javascript学习笔录9"+name+"</br>";
4 页面最近的更改时间
document.lastModified
5 页面的前导页面
document.referrer
6 页面的URl
document.URL
7 打开新的页面
window.open(url,name,features,replace)
这里说明一下,document 和window的区别:
document(文档对象)是window和frames对象的一个属性,是显示于窗口或框架内的一个文档。
window对象是Javascript的高级对象,是顶层对象,即浏览器窗口。而document则是window的对象,由于window是顶级对象,
所以window.document.write 一般省略 window :document.write
8 打印页面
window.print()
9 移动窗口
window.moveTo(x,y)
参数x,y :窗口左上角的坐标,单位为像素。绝对位置,即屏幕位置
window.moveBy(dx,dy)
参数dx:窗口在水平方向移动的距离,单位为像素。dx为正值向右移动
dy:窗口在垂直方向移动的距离,单位为像素。dy为正值向下移动。
相对位置,移动之后距离现在的位置。
10 改变窗体大小
window.resizeTo(width,height)
参数 width:窗口新宽度,单位为像素。
height:窗口新高度,单位为像素
window.resizeBy(dwidth,dheight)
参数 dwidth:窗口宽度变化量,可正可负,单位为像素。
dheight:窗口高度变化量,可正可负,单位为像素。
11 警告框
这个我经常用,有的时候项目里面如果有asp的改动的话,一般来说我都是用alert()和console.info()去调试的。
12提示对话框
window.prompt(string,string)
13 确认对话框
window.confirm("do you like that?")
让用户确认。
具体代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Js7.aspx.cs" Inherits="Javascript_Js7" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Javascript学习笔录9</title></head><body onload="window.status='welcome to my website'"> <form id="form1" runat="server"> <div> <a href =http://www.baidu.com>baidu</a> <input type="button" value="打印" onclick="window.print()" /> <br /> 水平方向<input type="text" name="x" value="20" /> <br /> 垂直方向<input type="text" name="y" value="30" /> <br /> <input type="button" value="移动窗口到。。。。" onclick="window.moveTo(document.form1.x.value,document.form1.y.value)" /> <input type="button" value="移动窗口" onclick="window.moveBy(document.form1.x.value,document.form1.y.value)" /> <input type="button" value="改变窗口大小到。。。" onclick="window.resizeTo(document.form1.x.value,document.form1.y.valu)" /> <input type="button" value="改变窗口大小" onclick="window.resizeBy(document.form1.x.value,document.form1.y.valu)" /> </div> <script> document.bgColor="orange"; document.write("background color is "+document.bgColor+"</br>"); document.fgColor="blue"; document.linkColor="red"; name="Mouse" document.title="Javascript学习笔录9"+name+"</br>"; document.write(document.title); document.write("本页面最后修改时间是"+document.lastModified+"</br>"); document.write("本页面URL:"+document.URL+"</br>"); document.write("本页面的引用页面时:"+document.referrer+"</br>"); window.open("http://www.baidu.com","taobao","width=200,heigh=200"); document.write("正文</br>") alert("welcome page7") name=window.prompt("输入用户名","用户名"); document.write("welcome "+name+"<br>"); confirms=window.confirm("are you sure"); if(confirms==true) document.write("Iam sure") else document.write(" I am not sure") </script> <h2>pls look this text</h2> <a href =http://www.newegg.com.cn>Newegg.cn</a> </form></body></html>
- Javascript学习笔录9(窗口属性操作-status、背景色、title等)
- secureCRT 设置背景色等操作
- Javascript学习笔录4(Javascript 定时器,ifelse等)
- MFC学习--对话框及窗口背景色
- MFC学习--对话框及窗口背景色
- javascript学习笔录6(Javascript元素的常用属性)
- 修改窗口背景色
- 改变窗口背景色
- 设置窗口背景色
- 设置窗口背景色
- 设置窗口背景色
- eclipse属性配置(背景色字体等)文件的导入导出方法
- eclipse属性配置(背景色字体等)文件的导入导出方法
- 【eclipse】eclipse属性配置(背景色字体等)文件的导入导出方法
- NSAttributedString用法简介,控制文字颜色,背景色等属性
- Javascript学习笔录10(字符串的操作)
- Javascript学习笔录11(日期的操作)
- Javascript学习笔录3(javascript的数组等一些体会)
- 某网站验证码的识别笔记【三】
- 如何才能自信?
- JBoss 6 发布WAR工程错误 Trying to resolve systemId as a non-file URL: xxxx 解决办法
- eclipse failed to create the java virtual machine 问题图文解析
- 多线程调试方法
- Javascript学习笔录9(窗口属性操作-status、背景色、title等)
- vi 常用命令行
- ajax异步上传输图片
- [VSTS] 配置 Team Foundation Server 团队权限最佳实践
- javascript操作table(insertRow(),deleteRow(),insertCell(),deleteCel...
- 动态代理
- 学习视频网站
- TCP/IP详解学习笔记(4)-ICMP协议,ping和Traceroute
- 持续集成过程中,临时文件太多导致编译不通过问题的解决方案