JavaScript Notes (4)

Practical sense of this small function used in web development on quite a lot less to do with the background timer: (retarder)

To specify a specific period of time after the implementation of certain procedures.

setTimeout (): (1.0 version)
Format:
[Timer object name =] setTimeout ("<expression>", ms)
Function: The Executive <expression> time.
Example 1:

<Script>
    function count() {
        setTimeout("alert(' Three seconds to  ')",3000)
    </Script>
    <INPUT TYPE="button" VALUE="  Countdown begins  ">

Example 2:

    <Script>

    function show() {
        document.all['news'].style.display = "";
        setTimeout("hide()",500);
    }

    function hide() {
        document.all['news'].style.display = "none";
        setTimeout("show()",500);
    }

    </Script>

    <Body onload="show()">
     Latest news  :<FONT> Ambush  ...</FONT>
    </Body>

clearTimeout (): Termination Timer

Format:

clearTimeout (timer object name)

setInterval (): (1.2 version)

Comparison of this function have feelings. Previous projects have used jQuery, that is the main use of this function.

Format:

[Timer object name =] setInterval ("<expression>", ms)

Function: Repeat the <expression>, up to the window, the frame is closed or the Executive clearInterval.

clearInterval (): Termination Timer

Format:

clearInterval (timer object name)

Example 1:

    <Script>

    var sec = 0;
    timerID = setInterval("count()",1000);

    function count() {
        num.innerHTML = sec++;
    }

    </Script>

     Residence time  :
    <FONT FACE="impact">0</FONT> Seconds
    <INPUT TYPE="button" VALUE=" Stop  ">

Example 2:

    <Script>

    var str = " This is an online auction Web site, please enjoy shopping!  !";
    var seq = 0;

    function scroll() {
        msg = str.substring(0, seq+1);
        banner.innerHTML = msg;
        seq++;
        if (seq >= str.length) seq = 0;
    }

    </Script>

    <Body onLoad="setInterval('scroll()',500)">
    <FONT></FONT>
    </Body>

This is a very beautiful --------------------< dividing line >--------------------

Image object:

Images on the page will automatically be seen as the image object, and according to the order, respectively for the document.images [0], document.images [1] ...
This is important, which also do not understand why sometimes write id or name, can find the picture!

The establishment of the image object:
Format:
Image Object Name = new Image ([width], [height]) / / px

Image object properties:
border complete height hspace lowsrc name src vspace width

Image object events:
onAbort onError onKeyDown onKeyPress onKeyUop onLoad

Example 1: (pre-set)

   <Script>

    img0 = new Image();
    img0.src = "images/snow0.gif";

    img1 = new Image();
    img1.src = "images/snow1.gif";

    document.write (" Already read two map files, but does not display  .");

    </Script>

Example 2:

   <Script>
    function img-preload(idx){
        eval("img"+idx+" = new Image()");
        eval("img"+idx+".src = 'images/snow"+idx+".gif'");
    }

    img-preload(0);
    img-preload(1);
    document.write (" Already read two map files, but does not display  .");

    </Script>

Example 3:
<Script>
function img-preload (imgname, idx) (
eval ("img" + idx + "= new Image ()");
eval ("img" + idx + ". src = 'images /" + imgname + ". gif'");
)

img-preload ("snow0", 0);
img-preload ("snow1", 1);
document.write ("already read the two map files, but does not appear at this time.");

</ Script>

This is a very beautiful --------------------< dividing line >--------------------

About the contents of this primary for my JavaScript is not useful,
When looking at these pictures on

Navigator object: (pilot)

Detect browser version, supported by the MIME type of the installed plug-ins (plug-in). The object contains two sub-objects: external object, MIME type object.

Navigator object properties:

Format: navigator. Attribute
JavaScript Notes (4)

Example 1:

<Script>

with (document) {
    write (" Your browser information  :<OL>");
    write ("<LI> Code  :"+navigator.appCodeName);
    write ("<LI> Name  :"+navigator.appName);
    write ("<LI> Version  :"+navigator.appVersion);
    write ("<LI> Language  :"+navigator.language);
    write ("<LI> Compile platform  :"+navigator.platform);
    write ("<LI> User table header  :"+navigator.userAgent);
}

</Script>

Example 2:

<Script>

if (document.all) {
   document.write(" Your browser is  :MSIE");
}   else {
   document.write(" Your browser is  :Navigator");
}

</Script>

plugin object's attributes:
Format: navigator.plugins. Attribute

JavaScript Notes (4)

Example:

  <Script>
    var len = navigator.plugins.length;
    with (document) {
        write (" Your browser has support for "+ len +"  plug-in:<BR>");
        write ("<TABLE BORDER>")
        write ("<CAPTION>PLUG-IN  Inventory  </CAPTION>")
        write ("<TR><TH> <TH> Name  <TH> Description  <TH> File name  ")
        for (var i=0; i<len; i++)
            write("<TR><TD>" + i +
                "<TD>" + navigator.plugins[i].name +
                "<TD>" + navigator.plugins[i].description +
                "<TD>" + navigator.plugins[i].filename);
    }

    </Script>

mimeType object's attributes:
Format: navigator.mimeTypes. Attribute

JavaScript Notes (4)

Example:

<Script>
var len = navigator.mimeTypes.length;
with (document) {
    write (" Your browser has support for "+ len +"  MIME Type  :");
    write ("<TABLE BORDER>")
    write ("<CAPTION>MIME type  Inventory  </CAPTION>")
    write ("<TR><TH> <TH> Name  <TH> Description  <TH> Extension  <TH> Note  ")
   for (var i=0; i<len; i++) {
       write("<TR><TD>" + i +
           "<TD>" + navigator.mimeTypes[i].type +
           "<TD>" + navigator.mimeTypes[i].description +
           "<TD>" + navigator.mimeTypes[i].suffixes +
           "<TD>" +
          navigator.mimeTypes[i].enabledPlugin.name);
}
}
</Script>

分类:Web 时间:2010-08-05 人气:201
分享到:
blog comments powered by Disqus

相关文章

  • ie8下修改input的type属性报错的解决方法 2014-07-31

    当用户勾选显示明文复选框时,要以明文显示用户输入的密码,去掉勾选时要变回密文,问题是ie8中是不允许修改input的type属性 摘要: 现在有一个需求如图所示,当用户勾选显示明文复选框时,要以明文显示用户输入的密码,去掉勾选时要变回密文,刚开始想到的就是修改输入框的type来决定显示明文还是密文,使用jQuery的attr来做试验,测试结果是chrome,Firefox,ie9+都是好的,在ie8以下就会报错,查找了下原因,ie8中是不允许修改input的type属性,最终换了种思路实现. 当

  • js修改input的type属性问题探讨 2014-08-08

    当input元素还未插入文档流之前,是可以修改它的值的,在ie和ff下都没问题.但如果input已经存在于页面,其type属性在ie下就成了只读属性了,不可以修改 js修改input的type属性有些限制.当input元素还未插入文档流之前,是可以修改它的值的,在ie和ff下都没问题.但如果input已经存在于页面,其type属性在ie下就成了只读属性了,不可以修改.在ff下仍是可读写属性. 今天遇到个问题,输入框有默认值"密码",但获得焦点时,"密码"两字会去掉,

  • js修改input的type属性及浏览器兼容问题探讨与解决 2015-01-07

    js修改input的type属性有些限制,今天遇到个问题一开始的时候,input的类型是text,后来变成了password类型.直观的思路是用js修改input的type类型.但ie下这么做不可行,所以只能换个思路感兴趣的朋友可以了解下 js修改input的type属性有些限制.当input元素还未插入文档流之前,是可以修改它的值的,在ie和ff下都没问题.但如果input已经存在于页面,其type属性在ie下就成了只读属性了,不可以修改.在ff下仍是可读写属性. 今天遇到个问题,输入框有默认

  • js清除input中type等于file的值域(示例代码) 2015-03-14

    本篇文章主要介绍了js清除input中type等于file的值域(示例代码) 需要的朋友可以过来参考下,希望对大家有所帮助 如下所示;var objFile = document.getElementById('fileID'); objFile.outerHTML=objFile.outerHTML.replace(/(value=\").+\"/i,"$1\"");

  • input标签-type属性 2014-05-28

    今天要讲的是按钮类型,分2种 1.普通的按钮:<input type="button" value="" onclick="return js代码;" 2.提交页面的按钮:<input type="submit" --/>

  • 移除HTML5 input在type="number"时的上下小箭头 2014-11-06

    在chrome下: input::-webkit-outer-spin-button, input::-webkit-inner-spin-button{ -webkit-appearance: none !important; margin: 0; } Firefox下: input[type="number"]{-moz-appearance:textfield;} 第二种方案: 将type="number"改为type="tel",同样是数

  • mysql regexp regular expression regular intersection type 2010-12-17

    Articles Category: Database Problem Description For example there are two records in table1 name no a 2,9 b 8,10 Then there are a bunch of strings, is 0,1,2,3,4 Then through a sql, find no record for the 2,9 to `` ` Because there are 2 strings, the d

  • struts2 custom type type conversion 2010-04-06

    struts2 custom type conversion in watched two kinds of (0). Preparation of the document type conversion file should inherit SrtutsTypeConverter, when after a succession automatically would override the two methods, one convertFromString (from client

  • struts2 result type Type 2008-12-14

    chain Action chain for handling com.opensymphony.xwork2.ActionChainResult dispatcher Is used to turn the page, usually dealing with JSP org.apache.struts2.dispatcher.ServletDispatcherResult freemaker FreeMarker template processing org.apache.struts2.

  • Oracle: Collections Records Type% TYPE% ROWTYPE 2010-11-09

    PL / SQL Collections and Records: http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm # 7658 Oracle Series: record of Record: http://blog.csdn.net/qfs_v/archive/2008/05/15/2446941.aspx Oracle PL / SQL how to use the% TYPE and%

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.365 (s). 12 q(s)