zoukankan      html  css  js  c++  java
  • 20150420 JavaScript——脚本语言 宿主文件

    JavaScript——脚本语言 宿主文件 NetScape JSscript JS
    一、JavaScript基本语法。
    (一)数据类型与变量类型。
    整数,小数,布局,字符串,日期时间,数组
    强制转换:
    parseInt() parseFloat() isNaN()
    (二)数组
    var 数组名 = new Array([长度]); //“假冒”数组
    a.length-长度
    a[下标] = 值。
    a[下标]
    (三)函数
    function 函数名(形参)
    {

    }
    function ShowStr(a)
    {

    }

    二、DOM操作
    DOM - Document Object Model 文档对象模型。 树
    线状模型,树状模型,网状模型
    window
    history
    location
    document <html></html>
    head
    body
    a,img,table,ul,ol.....
    status

    对象——object 特点的名词 行为的动词

    (一)window
    1.alert()
    window.alert();

    2.[var a = ]window.confirm("你能跑过豹子吗?");
    //prompt(); --不常用,不用记,输入
    3.open();
    open("地址","_blank/_self","新窗口的特点");
    [var a = ]window.open("http://www.sina.com.cn");
    在新窗口中打开页面,返回新的窗口。a也是一个window类型的变量。
    详细需要翻译。

    4.close();
    window.close();

    5.setTimeout("code",毫秒数)
    指定的毫秒数后,执行code一次。
    function showTime()
    {
    var date = new Date();
    document.getElementById("hh").innerHTML = date;
    window.setTimeout("showTime()",1000);

    }
    window.setTimeout("showTime()",1000);

    ********打开页面,五秒后弹出广告,再过5秒广告窗口关闭************
    var a;
    function openAD()
    {
    a = window.open("http://www.sina.com.cn","_blank","width=200 height=200 toolbar=no top=0 left=0");

    window.setTimeout("closeAD()",5000);
    }
    function closeAD()
    {
    a.close();
    }
    window.setTimeout("openAD()",5000);

    6.setInterval("code",毫秒数)
    每隔指定的毫秒数就执行code一次。
    //
    function showTime()
    {
    var date = new Date();
    document.getElementById("hh").innerHTML = date;
    }
    window.setInterval("showTime()",1000);


    window.moveTo(x,y);
    window.resizeTo(width,height);
    window.scrollTo(x,y);


    (二)历史操作
    window.history.go(n)
    (三)地址栏操作
    window.location.href
    //定时刷新页面
    function showSelf()
    {
    window.location.href="Untitled-3.html";
    }
    window.setInterval("showSelf()",1000);

    (四)文档操作
    window.document

  • 相关阅读:
    字符串与字典常用命令
    Python学习之路:字符串常用操作
    Python学习之路:购物车实例
    面试题2017
    c#语法学习
    结构化设计模式-桥接模式
    结构型设计模式-适配器模式
    .Net Cache
    设计模式的六大原则
    uml类图关系
  • 原文地址:https://www.cnblogs.com/m123/p/4443624.html
Copyright © 2011-2022 走看看