javascript ×Ö·û´®´¦ÀíÈ«¹¥ÂÔ£¨×ª£©
javascript ×Ö·û´®´¦Àí
Ò»¡¢ÉùÃ÷×Ö·û´®:
var normal_monkey = "I am a monkey!<br>";
document.writeln("Normal monkey " + normal_monkey);
var bold_monkey = normal_monkey.bold();
document.writeln("Bold monkey " + bold_monkey);
ÕâÀïµÄÉùÃ÷£º var bold_monkey = normal_monkey.bold();
ºÍÏÂÃæ¶ÔÉùÃ÷ÊǵÈͬµÄ£º
var bold_monkey = "<b>" + normal_monkey + "</b>";
µÚ1¸ö°æ±¾µÄÉùÃ÷¿´ÆðÀ´Òª¼òÃ÷µÃ¶à¡£ÕâÀïÓõ½ÁË×Ö·û´®¶ÔÏóÖÐ
µÄbold¶ÔÏ󣬯äËûµÄ×Ö·û´®¶ÔÏó»¹ÓÐindexOf, charAt,
substring, ÒÔ¼°split, ÕâЩ·½·¨¿ÉÒÔÉîÈë×Ö·û´®µÄ×é³É½á¹¹¡£
Ê×ÏÈÎÒÃÇÑо¿Ò»ÏÂindexOf¡£
2¡¢indexOf
indexOfÓÃÓÚ·¢ÏÖһϵÁеÄ×Ö·ûÔÚÒ»¸ö×Ö·û´®ÖеÈλÖò¢¸æËßÄã×Ó×Ö·û´®µÄÆðʼλÖá£Èç
¹ûÒ»¸ö×Ö·û´®Öв¿°üº¬¸Ã×Ó×Ö·û´®ÔòindexOf·µ»Øreturns "-1."
Àý×Ó£º
var the_word = "monkey";
//ÈÃÎÒÃÇ´Óµ¥´Ê "monkey"¿ªÊ¼¡£
var location_of_m = the_word.indexOf("m");
//location_of_m(×ÖĸmµÄλÖÃ)½«Îª0£¬ÒòΪ×ÖĸmλÓÚ¸Ã×Ö·û´®µÄÆðʼλÖá£
var location_of_o = the_word.indexOf("o");
//location_of_o(×ÖĸoµÄλÖÃ)½«Îª1¡£
var location_of_key = the_word.indexOf("key");
//location_of_key(keyµÄλÖÃ)½«Îª3ÒòΪ×Ó×Ö·û´®“key”ÒÔ×Öĸk¿ªÊ¼£¬¶øk
ÔÚµ¥´ÊmonkeyÖеÄλÖÃÊÇ3¡£
var location_of_y = the_word.indexOf("y");
//location_of_y)×ÖĸyµÄλÖÃ)ÊÇ5¡£
var cheeky = the_word.indexOf("q");
//cheekyÖµÊÇ-1£¬ÒòΪÔÚµ¥´Ê“monkey”ÖÐûÓÐ×Öĸq¡£
indexOf¸üʵÓÃÖ®´¦:
var the_email = prompt("What’s your email address?", "");
var the_at_is_at = the_email.indexOf("@");
if (the_at_is_at == -1)
{
alert("You loser, email addresses must
ha
Ïà¹ØÎĵµ£º
ÍøÒ³¿É¼ûÇøÓò¿í£ºdocument.body.clientWidth
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.clientHeight
ÍøÒ³¿É¼ûÇøÓò¿í£ºdocument.body.offsetWidth(°üÀ¨±ßÏߵĿí)
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.offsetHeight(°üÀ¨±ßÏߵĿí)
ÍøÒ³ÕýÎÄÈ«ÎÄ¿í£ºdocument.body.scrollWidth
ÍøÒ³ÕýÎÄÈ«Îĸߣºdocument.body.scrollHeight
ÍøÒ³±»¾íÈ¥µ ......
constructorÊôÐÔʼÖÕÖ¸Ïò´´½¨µ±Ç°¶ÔÏóµÄ¹¹Ô캯Êý¡£±ÈÈçÏÂÃæÀý×Ó£º
// µÈ¼ÛÓÚ var foo = new Array(1, 56, 34, 12);
var arr = [
1
,
56
,
34
,
12
];
console.log(arr.constructor === Array); ......
<script type="text/javascript">
function checkform() {
//ÅжϱêÌâÀ¸ÊÇ·ñÌîд
if (document.form1.title.value == "") {
alert("ÐÅÏ¢ÀàÐͲ»ÄÜΪ¿Õ£¡");
&nb ......
µ¹¼ÆÊ±¼ÆËã
<body>
<div id="countdown"></div>
<mce:script type="text/javascript"><!--
var i = 0;
(function(){
var hour, min, sec, text;
tmp = 12 * 60 * 60 - i;
hour = Math.floor(tmp / 3600);
tm ......
´´½¨¶¯Ì¬º¯Êý£¨ÔÚc/c++ÖÐÀûÓú¯ÊýÖ¸ÕëÀ´ÊµÏÖ£©
var FunctionName = new Function(argument1,...,lastargument);
˵Ã÷£º
ËùÓеIJÎÊý¶¼±ØÐëÊÇ×Ö·û´®ÀàÐ͵ģ¬×îºóµÄÒ»¸ö²ÎÊý±ØÐëÊÇÕâ¸ö¶¯Ì¬º¯ÊýµÄ¹¦ÄܳÌÐò´úÂë¡£
<script type="text/javascript">
& ......