Javascript学习笔录9(窗口属性操作-status、背景色、title等)

25 篇文章 0 订阅
16 篇文章 0 订阅

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 οnlοad="window.status='welcome to my website'">
    <form id="form1" runat="server">
    <div>
    <a href =http://www.baidu.com>baidu</a>
    <input type="button" value="打印" οnclick="window.print()" />
    <br />
    水平方向<input type="text" name="x" value="20" />
    <br />
    垂直方向<input type="text" name="y" value="30" />
    <br />
    <input type="button" value="移动窗口到。。。。" οnclick="window.moveTo(document.form1.x.value,document.form1.y.value)" />
    <input type="button" value="移动窗口" οnclick="window.moveBy(document.form1.x.value,document.form1.y.value)" />
    <input type="button" value="改变窗口大小到。。。" οnclick="window.resizeTo(document.form1.x.value,document.form1.y.valu)" />
    <input type="button" value="改变窗口大小" οnclick="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>




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值