<Script Language = "JavaScript">
* ***** JavaScript sentence ******
</Script>
1. Place it between
For example, "Hello!" is displayed on the webpage !".
<Html>
<Body>
<Script Language = "JavaScript">
Alert ("Hello! ")
</Script>
</Body>
</Html>
2. Directly merge rows at the zookeeper address
You can also enter JavaScript statements in the address bar of the browser, which can be directly executed by the browser.
For example, enter javascript: alert (200*75)
3. Call JavaScript files
You can save the pure JavaScript statement in another "*. js" file and call it if necessary.
Example: Call the test. js file and a prompt is displayed.
<Html>
<Body>
/* Call the test. js file */
<Script language = "JavaScript" src = "test. js">
</Script>
</Body>
</Html>
The content of the test. js file is as follows:
Alert ("this is the called statement. ")
Iv. Use of Variables
Variable Declaration: var usename
Variable value: usename = "Li Guoqiang"
Example: "Hello, Li Guoqiang!" is displayed on the webpage !".
<HTML>
<Body>
<Script language = "JavaScript">
VaR usename
Usename = "Li Guoqiang"
Alert (usename + "Hello! ")
</SCRIPT>
</Body>
</Html>
5. Array
Array definition: var name = new array (5) uses new to generate an array.
Array Value assignment: name [1] = "marry"
Array initialization: var name = new array ("marry", "petty", "Mike", "jphn ")
Array reference: name [1]
6. prevent others from exploiting the loopholes
<Script language = JavaScript>
<! --
If (top. location! = Self. Location)
Top. Location = self. location;
// --> </SCRIPT>
Put it in the
VII,JavaScript code for dynamically adjusting the height of iframe
Iframe, especially the iframe without borders, is possible to update part of the page data without refreshing a new page because it can be seamlessly integrated with the webpage, however, the size of the iframe is not as flexible as that of the layer, which makes it difficult to use it. It is not good to set the height of the iframe when it is too large or less. Now, let me tell you a way to dynamically adjust the height of iframe, mainly the following JS functions:
Function SetWinHeight (obj)
{
Var win = obj;
If (document. getElementById)
{
If (win &&! Window. opera)
{
If (win. contentDocument & win. contentDocument. body. offsetHeight)
Win. height = win. contentDocument. body. offsetHeight;
Else if (win. Document & win. Document. body. scrollHeight)
Win. height = win. Document. body. scrollHeight;
}
}
}
Finally, add iframe and you cannot discard the onload attribute. Of course, the id must also match the win attribute in the function.
<Iframe width = "778" align = "center" height = "200" id = "win" name = "win" onload = "Javascript: SetWinHeight (this) "frameborder =" 0 "scrolling =" no "> </iframe>