One, javascript placement, annotation, output tool 1, output tool A, alert (), belongs to the Global function in window. Whatever is written, it is output as a string. B, document.write (); Output content to Web pages.
C, var vlaue=prompt ("Display content", "text box display content") value is the return value; pops up an input box to receive parameters.
<script>
alert(123);
document.write(");
var i=prompt("你好","请问你是?");
alert(i);
</script>
2, JavaScript How to place in HTML page A, <script type= "Text/javascript" language= "JavaScript" ></script> label pair form. Let the browser recognize that JavaScript starts there and ends there. (1)type= "Text/javascript" allows the browser to recognize JavaScript language(2) can be called at any position in head or body
(3) but they are still a whole that are interconnected and interact with each other. As a whole.
b, you can call JavaScript in a hyperlink or redirect (you must start with javascript: "" to wrap it up and let the browser recognize the JavaScript codehyperlink format: "Javascript:alert (' I am a hyperlink ') 'Redirection format: "action=" Javascript:alert (' I am a form ') '
<a href="javascript:alert(‘我是超链接‘);">链接</a>//超连接
<form action="javascript:alert(‘我是表单‘)" method="post">//重定向
<input type="text" name="names"/>
<input type="submit" value="提交"/>
</form>
C. Call after an event
format: onclick= "Javascript:alert (' I am an event ')"
<div onclick="javascript:alert(‘我是事件‘)">我是事件</div>
ie under the special event call, Firefox Google does not support:
<script for="one" event="onclick">
alert(我是IE特有事件);
</script>
<body>
<div id="one">我是IE特有事件</div>
</body>
D. Calling external JavaScript files
* cannot have any code in the call page <script> tag pair
* Tag pairs cannot appear in JS script
* All JS are a whole, are interconnected, affect each other
format: <script src= "file path" ></script>
- JavaScript files written in
var a="你好世界"
alert(a);
<!--html页面中-->
<script src="文件路径"></script>
3. CommentsA, the browser against the long
(1) <!--xxxxxxxx--> as HTML code masking
B. Normal comment
(2)//xxxxxxxx single-line comment
(3)/*xxxxxxxx*/multi-line annotation
From for notes (Wiz)
JavaScript Learning Notes (ii)