Description: On the status bar, visitors stay on this page (such as: You stay on this page for x hours x minutes x seconds)The problem is to design a timer that shows how long the viewer has stayed on the page. To solve this problem, I think of the
In IE7, IE8, the Close () method provided with JavaScript closes the current window or tag, but prompts the annoying dialog box to find the code and can finally be closed without prompting.
JavaScript code
Copy Code code as follows:
Today in doing similar to QQ comment function, helpless, searching the internet everywhere to find the answer, finally in a very small corner of the inspired. Met a new thing contenteditable.
The HTML code is as follows:
Copy Code code as
Use substring () or slice ()
Function: Split ()Function: To store a string partition into an array using a specified delimiterExample:
Copy Code code as follows:
Str= "Jpg|bmp|gif|ico|png";
Arr=thestring.split ("|");
Arr is an
Copy Code code as follows:
ZF = Accadd (ZF, parsefloat ("12.11"));
The addition function, which is used to get the exact addition result.
Description: JavaScript addition results will be error, in two floating-point number added when it is
Today in the JS file, write El expression cannot get the value (code below), Baidu a turn, is summarized as follows:
1, JavaScript is client-side execution, El is performed on the server, and the server is executed before the client, so the value
Many Web pages are frame-structured, and in many cases, clicking events or links through a button, and jumping out of the frame to other interfaces. For example, click "Logout Login" to return to the login interface.
One, by running the script to
JavaScript language design is not rigorous, many places will be careless error.For example, consider the following scenario.Now, we want to determine whether a global object MyObj exists, and if not, declare it. The algorithms described in natural
When writing a JS script often encountered objects are empty or not the object of the situation, we can use if to judge it, and then to carry out the corresponding processing methods, the specific judge their methods are as follows:
1, if (typeOf
Prompts Stack overflow at line:0 when opening a Web page. I made a screenshot as follows:
After analysis, found in the Web page is similar to the following code:
Analysis: Pay special attention to onerror, when the picture does not exist, will
When using an asynchronous request, sometimes it is necessary to return the result of the asynchronous request to another JS function, in which case there will be an asynchronous request return request result, the request is in the JS function has
As shown below:
Copy Code code as follows:
To delete all options in a select dynamically:
function Delalloptions () {
document.getElementById ("User_dm"). options.length=0;
}
To delete an option in a select dynamically:
function
In the Web page we sometimes need to control the text input box "input state", some key properties can not be modified, this time need to set the text input box ReadOnly property to False, in the Web page we can use
But in JS we can not eat
Timer settimeout () and SetInterval () two are all JS functions of the timing function two a little different.
SetTimeout ():
Explanation in the JS manual: used to call a function or evaluate an expression after a specified number of
Note: IE7, and IE8 have a copy of the permissions on the Web page, you need to set in the "Custom Level" script in "security"
Clipboarddata objects
Provides access to the Clipboard.
Three methods1.clearData (Sdataformat) deletes data in the
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