易截截图软件、单文件、免安装、纯绿色、仅160KB

JavaScript方法和技巧大全

             JavaScript方法和技巧大全
1:基础知识
1 创建脚本块
1: <script language=”JavaScript”>
2: JavaScript code goes here
3: </script>
2 隐藏脚本代码
1: <script language=”JavaScript”>
2: <!--
3: document.write(“Hello”);
4: // -->
5: </script>
在不支持JavaScript的浏览器中将不执行相关代码
3 浏览器不支持的时候显示
1: <noscript>
2: Hello to the non-JavaScript browser.
3: </noscript>
4 链接外部脚本文件
1: <script language=”JavaScript” src="/”filename.js"”></script>
5 注释脚本
1: // This is a comment
2: document.write(“Hello”); // This is a comment
3: /*
4: All of this
5: is a comment
6: */
6 输出到浏览器
1: document.write(“<strong>Hello</strong>”);
7 定义变量
1: var myVariable = “some value”;
8 字符串相加
1: var myString = “String1” + “String2”;
9 字符串搜索
1: <script language=”JavaScript”>
2: <!--
3: var myVariable = “Hello there”;
4: var therePlace = myVariable.search(“there”);
5: document.write(therePlace);
6: // -->
7: </script>
10 字符串替换
1: thisVar.replace(“Monday”,”Friday”);
11 格式化字串
1: <script language=”JavaScript”>
2: <!--
3: var myVariable = “Hello there”;
4: document.write(myVariable.big() + “<br>”);
5: document.write(myVariable.blink() + “<br>”);
6: document.write(myVariable.bold() + “<br>”);
7: document.write(myVariable.fixed() + “<br>”);
8: document.write(myVariable.fontcolor(“red”) + “<br>”);
9: document.write(myVariable.fontsize(“18pt”) + “<br>”);
10: document.write(myVariable.italics() + “<br>&rdquo


相关文档:

JavaScript 获取对象的高度和宽度详细说明

scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......

javascript调用java代码,el表达式

我们在jsp页面上的js脚本中可以调研java代码,比如,我们需要再js中用alert函数显示服务器端发送过来的某个字符串那么我们可以这样做
tomcat下:
在服务器端我们有request.setAttribute("name","abc");
那么我要在页面上用alert显示的话,有两种方式:
1、使用EL表达式
  在El表达式的外面用引号即可:
<scri ......

a标签中的href,onclick,#,javascript:void简要分析

<script type="text/javascript">
window.onbeforeunload=function()
{
alert("onbeforeunload event...");
//return false;
}
</script>
<a href="#" onclick="return true;">测试1</a><br/>
<a href="javascript:void(0)" onclick="return true;">测试2</a><br/& ......

JavaScript:prototype属性使用方法

一、基本使用方法
      prototype属性可算是JavaScript与其他面向对象语言的一大不同之处。
简而言之,prototype就是“一个给类的对象添加方法的方法”,使用prototype属性,可以给类动态地添加方法,以便在JavaScript中实现“继承”的效果。
    & ......

如何正确的加载javascript文件

1) 为什么加载javascript文件很重要?
javascript文件是比较特殊的,因为浏览器加载javascript是串行的。以为着在加载Javascript文件的时候,其他一切资源的下载包括页面的显示都会被阻塞。
2) 如何正确的加载JavaScript?
a. 将JavaScript文件放在页面的最后
因为JavaScript的加载会阻塞页面的显示,所以将JavaScrip ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号