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

JavaScript in 10 Steps or Less

没有按别人的推荐,学什么圣经类的js书,而是随便挑了本《JavaScript in 10 Steps or Less》。
花了3个小时,看了30个task。
讲的非常浅显详细。虽然是E文,但很浅显易懂。
task31:
Calling Functions from Tags
One of the benefits of JavaScript is to be able to tie interactivity to elements of the HTML page. One way you can do this is to set up links in HTML that actually trigger calls to JavaScript functions when the link is clicked.
There are two ways to do this:
1. Use the onClick attribute of the a tag to call the function:
<a href=”#” onClick=”functionName()”>Link text</a>
2. Use a javascript: URL in the href attribute of the a tag to call
the function:
<a href=”javascript:functionName()”>Link text</a>
The following task illustrates these two methods of calling a function from a link by creating a function that displays an alert dialog box to the user and then providing two separate links for the user to use to call the function:
1. Open a new HTML document in your preferred HTML or text editor.
2. Create the header of the document with opening and closing head tags:
<head>
</head>
3. Insert a script block in the header of the document:
<script language=”JavaScript”>
<!--
// -->
</script>
4. Create a function named hello that takes no arguments:
function hello() {
}
5. In the function, use the window.alert method to display an alert
dialog box:
window.alert(“Hello”);
6. Create the body of the document with opening and closing body tags.
7. In the final page create two links that call the hello function using
onClick and the javascript: URL techniques so that the final
page looks like Listing 31-1.
<head>
<script language=”JavaScript”>
<!--
function hello() {
window.alert(“Hello”);
}
// -->
</script>
</head>
<body>
<a href=”#” onClick=”hello()


相关文档:

JavaScript 对象字面量

http://bei123wang.blog.163.com/blog/static/23175492009113022048840/
JavaScript 对象字面量
javascript 2009-12-30 14:20:48 阅读7 评论0 字号:大中小
JavaScript 对象字面量
在编程语言中,字面量是一种表示值的记法。例如,"Hello, World!" 在许多语言中都表示一个字符串字面量(string literal ),JavaScript ......

JavaScript去除空格的三种方法 (trim)

<SCRIPT LANGUAGE="JavaScript">
<!--
// Trim() , Ltrim() , RTrim()
String.prototype.Trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
 
String.prototype.LTrim = function()
{
return this.replace(/(^\s*)/g, "");
}
 
String.prototype.RTrim = functio ......

JavaScript正则表达式 进阶

正则表达式是一个描述字符模式的对象。
JavaScript的RegExp对象和String对象定义了使用正则表达式来执行强大的模式匹配和文本检索与替换函数的方法.
'***********************
'              \\JavaScript//
'
'***********************
在JavaSc ......

JavaScript CSS Style属性对照表

JavaScript代码
<mce:script type="text/javascript"><!--
function imageOver(e) {
e.style.border="1px solid red";
}
function imageOut(e) {
e.style.borderWidth=0;
}
// --></mce:script>
<img src="phplamp.gif" onmouseover="imageOver(this)" onmo ......

javascript开发系列(运算符)

今天在补习javascript中。遇到几个相对陌生的运算符,特别在此写下来。
1、三元运算符?:,这是js中唯一一个三元运算符(这和C#中的一样),用法如下
   var x=1;
  var y=3;
  (x>y)?(x-y):(y-x);
2、typeof运算符
  typeof 是一个一元运算,放在一个运算数之前,运算数可以是任意类型。 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号