Method One, SetAttributevar obj = document.getElementById ("obj");
Obj.setattribute ("onclick", "Javascript:alert (' Test ');");
This uses setattribute to specify the onclick attribute, simple, well understood,
However: IE does not support, IE does
Let's take a look at the effect chart.
Instance Code
#box {margin:100px auto;
width:200px;
height:150px;
line-height:150px;
letter-spacing:10px;
Text-align:center;
font-size:30px;
Each JavaScript function has a prototype attribute (the JavaScript object does not have this attribute), which references an object that is a prototype object. JavaScript allows us to modify this prototype object.
There are 2 different ways to
No error prompts are seen in the Firebug. Open IE to meet the damned "not yet implemented error", according to the location of the hint in IE find the past also did not find any errors, it seems that the error location of IE is not too accurate.
In Ie7/firefox 3.0/google Chrome passed the test
Closedemo.htm
Copy Code code as follows:
Attention
If you are using a Firefox browser you must make the following settings
1, in the Address bar input about:config and then
Copy Code code as follows:
var str = "Hello";
str = "World";
Work in the background:
1 creates a string that stores "Hello" and causes Str to point to it.
2 Create a string that stores "world".
3 Create a string that stores the
no Geturl and Fscommand methods .
The ActionScript used by Flash is very similar to JavaScript, and the following describes how to invoke each other's functions:
1:javascript call a function in FlashAdd in Flash Scripts
Import
iframe Learning ; Input type= "button" value= "Change src" onclick= "changesrc ();"/>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
In order for the function to be executed only after the page is loaded, we bind the function to the OnLoad event:
Window.onload = Userfunction
But what if there are two functions: Firstfunction () and Secondfunction (), and want them to be
Definitions and usage
The ToFixed () method can be rounded to a number that specifies the number of decimal places.
Grammar
numberobject.tofixed (num) parameter description
Num required. Specify the number of digits, which are values between 0 ~
Definition: Define a series of algorithms, encapsulate them into functions, or encapsulate them into an object as attributes, and then define a method that automatically chooses to perform the corresponding algorithm based on the parameters.
First, define a JavaScript function , as follows:
function Puckermenu (level) {
var levellength = (' row ' + level). Length;
var toDo = ' 0 ';
for (var icount = 0; icount 1 && (Document.all[icount].id.length > Levellength) {
if document.all
In fact, this problem and browser version is closely related, as a rookie of me, until now also did not find the perfect solution. No way, because the business has to be implemented, so have to do it in another way:
"Close" the old window while
ObjectJavaScript operations are all about objects. Arrays are objects, and functions (function) are objects. Object (Type). So what is an object? The object is the name-value pair (name-value). The name is a string, and the value can be a string,
object-oriented javascript:using the ' Prototype ' property
Starting with JavaScript 1.1, it has a built-in object called prototype. With it, you can extend JavaScript and write custom properties and methods on objects. For instance. The following
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service