• 2014.9.23window对象


    一、window对象

    Wondow.navigate(url); 跳转页面(与超链接的区别:可以加逻辑条件)

    Var a = Math.random(); 0-1之间随机数

    Var a = parseInt(Math.random()*10000)%3  随机0,1,2

    Document.write(a);

    Window.moveTo(0,0); 移动窗口到0,0的位置

    window.resizeTo(200,200) 移动调整窗口大小

    window.showModalDialog(“1.html”); 打开模态对话框(模态对话框:只要不关,其他窗口无法操作)永远置顶

     

    dialogArgument(“url”,“值”,“dialogWidth=”“;dialogLeft=””;dialogHeight=”“;center=yes”) 在模态对话框接受传过来的值

    dialogArgument(”url,数据参数,特征参数“)

    数据参数:在对话框页面中,用dialogArgument获得

    特征参数:用分号隔开,像素大小要加上px。dialogHeight,dialogWidth,center

    window.showModelessDialog(); 非模态对话框(置顶,但是其他窗口可以操作)其参数与showModalDialog相同

    Window.scrollTo(0,10000); 滚动到坐标是0,10000的地方

    二、window.History对象

    window.History.back() 后退

    window.History.foward() 前进

    window.History.go(n) n是数字,n是正数——前进,n是负数——后退

    三、window.location对象

    Window.location.href; 获得本页面的地址,href是属性,地址栏的地址

    Hostname主机名,域名,网站名

    Pastname 路径名。?后面不是路径

    Protocol:协议名

    四、window.status 给状态栏赋文字

    Window.status=”好了,小苹果“;

    五、window.document 对象

    (一)找到元素

    1.getElementById()——最多找一个

    2.getElementsByName()——找出来的是个数组

    3.getElementsByTagName()——找出来的是个数组

    4.getElementsByClassName()——找出来的是个数组

    (二)操作内容

    第一类:非表单元素:

    1.获取内容

    a.innerHTML 获取ID内的所有内容

    a.innerTEXT 只获取ID内的文字内容

    a.outHTML 获取外部的HTML,包括标签本身的内容,<div>...</div>

    2.设置内容

    a.innerHTML = “<font color=red>hello world</font>”;

    3.清空内容

    赋空字符串

    第二类:表单元素:

    Var t = document.getElementById(“t1”);

    Alert(t.value); 获取input中的value值,或者<textarea></textarea>中间的值

    Alert(t.innerHTML); 获取元素

    t.value = “内容改变了”; 改值

    (三)操作属性

    a.setAttribute(“disabled”,”disabled”); 设置属性,按钮不可用

    a.getAttribute(“type”); 获取属性

    a.removeAttribute(“disabled”); 移除属性

    (四)操作样式

    1.直接操作样式属性

    a.style.xxxx="";

    var s = a.style.xxxx;

     

  • 相关阅读:
    bzoj 3308 九月的咖啡店
    8.13模拟赛
    8.10模拟赛
    8.9模拟赛
    8.8模拟赛
    Codeforces Round #406 (Div. 2) D. Legacy (线段树建图dij)
    BZOJ 2957: 楼房重建 (分块)
    SPOJ BGSHOOT
    Codeforces Round #404 (Div. 2) E. Anton and Permutation(树状数组套主席树 求出指定数的排名)
    Lightoj-1356 Prime Independence(质因子分解)(Hopcroft-Karp优化的最大匹配)
  • 原文地址:https://www.cnblogs.com/zsmj001/p/3989384.html
Copyright © 2020-2023  润新知