JavaScript Notes (4)
Advertisements
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
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
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
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>
Related Posts of JavaScript Notes (4)
-
Build flex + spring + blazeds + hibernate application
Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...
-
Nan-Jing 5: When IBatis.Hibernate mixed affairs, pay attention to your SQL
[Problem] Now, in the development of the so-called multi-storey JavaEE applications, data persistence layer is always essential, and "Automatic" of ORM - Hibernate, and "all-manual-type" of SqlMap - IBatis, equivalent data are Per ...
-
Hibernate connection pool configuration
Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15
-
hibernate to use the principle of
The use of hibernate, implementation of data persistence. Has the following several processes. One configuration database connection information. Hibernate.config 2 configuration mapping. 3 use: the use of the process are the following steps: 3.1: Ge ...
-
hibernate generic generic DAO
package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *
-
Struts2 + hibernate + spring problem user log in
dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q
-
Based on JDBC, JPA Annotation achieve simple CRUD Generic Dao
The origin of ideas are pretty long history of reasons: [Use iBATIS history] The use of iBATIS has been a long time, the system is to use the CRUD template tool to generate the code, although there are tools to generate, but looked at a lot of CRUD the Sq
-
Hibernate secondary cache
Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...
-
Hibernate's lazy strategy
hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...












