JavaScript方法和技巧大全——基础知识(1)
2010-09-14 13:40:07 来源:WEB开发网创建脚本块
1<script language=”JavaScript”>
2JavaScript code goes here
3</script>
隐藏脚本代码
1<script language=”JavaScript”>
2<!--
3document.write(“Hello”);
4-->
5</script>
浏览器不支持的时候显示
1<noscript>
2Hello to the non-JavaScript browser.
3</noscript>
链接外部脚本文件
1<script language=”JavaScript” src="/”filename.js"”></script>
注释脚本
1// This is a comment
2 document.write(“Hello”); // This is a comment
3 /*
4 All of this
5 is a comment
6 */
输出到浏览器1document.write(“<strong>Hello</strong>”);
定义变量
1var myVariable = “some value”;
字符串相加
1var myString = “String1” + “String2”;
字符串搜索
1<script language=”JavaScript”>
2 var myVariable = “Hello there”;
3 var therePlace = myVariable.search(“there”);
4 document.write(therePlace);
5</script>
字符串替换
1<script language=”JavaScript”>
2 thisVar.replace(“Monday”,”Friday”);
3</script>
Tags:JavaScript 方法 技巧
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接