函数function可以被认为是Object的子类,也就是一个function对象可以拥有自己的变量和其它function对象当属性。
<html>
<body>
<input type='button' id='btn1' value='按钮1'/>
<input type='button' id='btn2' value='按钮2'/>
<script type='text/javascript'>
function doClick(str){
if(str!=undefined)
alert(str);
else
alert('varible undefined');
}
document.getElementById('btn1').onclick=doClick;
document.getElementById('btn2').onclick=function(){
doClick('按钮2');
}
</script>
</body>
</html>
以上这段代码可以用来展示带参数的 函数的调用情况,不过在firefox下,点击btn1,alert的是“object MouseEvent",而在ie下点击btn1,alert的是"varible undefined"。
似乎在firefox下面,如果调用的时候没有指定参数,那么就把鼠标事件当参数传递给函数。
分享到:
相关推荐
15. JavaScript Functions, Objects, and Arrays 16. JavaScript and PHP Validation and Error Handling 17. Using Ajax 18. Introduction to CSS 19. Advanced CSS with CSS3 20. Accessing CSS from JavaScript ...
–What makes JavaScript functions so unique –The various ways to create objects –How to define your own constructors –How to work with and understand prototypes –Inheritance patterns for types and...
This file contains JavaScript functions to convert ASCII math notation and LaTeX to Presentation MathML. Simple graphics commands are also translated to SVG images. The conversion is done while the (X...
Understand the basic usage and mechanics of JavaScript functions Explore objects and object-oriented programming Tackle new concepts such as iterators, generators, and proxies Grasp the complexities ...
Use JavaScript functions and timers Perform analog and digital I/O Work with expansion capes and modules Design Web interfaces that control electronics Assemble and program a robot and an e-mail ...
JavaScript Objects Functions and Arrays Explained covers a lot of material as you may see from the index below. However, each chapter is self-contained and easy to understand with plenty of ...
This book covers the WebGL 1.0 API along with all related JavaScript functions. You will learn how HTML, JavaScript, and WebGL are related, how to set up and run WebGL applications, and how to ...
12 Exporting C functions to JavaScript 13 Calling JavaScript functions from C 14 Preamble Conversion Functions 15 Emscripten Module & Memory Buffer 16 Debugging 17 Runtime Initialisation 18 Emrun ...
12 Exporting C functions to JavaScript 13 Calling JavaScript functions from C 14 Preamble Conversion Functions 15 Emscripten Module & Memory Buffer 16 Debugging 17 Runtime Initialisation 18 Emrun ...
12 Exporting C functions to JavaScript 13 Calling JavaScript functions from C 14 Preamble Conversion Functions 15 Emscripten Module & Memory Buffer 16 Debugging 17 Runtime Initialisation 18 Emrun ...
Mathematical Functions in Javascript
Display web content on your program and interact with it by calling JavaScript functions from C++, or calling C++ functions from the web content Access to MySQL and SQLite databases to retrieve data ...
Use the simple ASP.NET API in SignalR for creating server-to-client remote procedure calls (RPC) that call JavaScript functions in client browsers from server-side .NET code. Exploit the API for ...
What Is JavaScript Functions
If there was ever a universal common.js shared among the entire develosphere, you’d ... So without further ado, here are what I believe to the top ten greatest custom JavaScript functions in use today.
Display web content on your program and interact with it by calling JavaScript functions from C++, or calling C++ functions from the web content Access to MySQL and SQLite databases to retrieve data ...
Precise and practical explanations of JavaScript’s functions and variable scoping semantics Useful JavaScript programming patterns and idioms, such as options objects and method chaining In-depth ...
You should understand the basics of JavaScript functions and variables and be comfortable with using CSS or a CSS framework for styling your projects. Table of Contents Chapter 1 Getting started ...
深入理解JavaScript系列(15):函数(Functions) 深入理解JavaScript系列(16):闭包(Closures) 深入理解JavaScript系列(17):面向对象编程之一般理论 深入理解JavaScript系列(18):面向对象编程之...