Principle: Recognition based on navigator.useragent return value
Realize:
Copy Code code as follows:
function Validbrowser () {
var u_agent = navigator.useragent;
var browser_name= ' Failed to identify the browser ';
if
The function of the SetInterval action is to call the function, method, or object at a certain time when the animation is played. You can use this action to update a variable or update time display from a database.
The syntax format for the
Implementation principle:Automatically invoke script to refresh frame page code every 1 seconds when loading index.htm
Code Benefits:You only need to set up the script in the Index.html frames page, and calling the loaded subpage does not require
Closures are a very important feature of ECMAScript, but it is difficult to describe them in a suitable definition. Although closures are difficult to describe clearly, they are easily created, or inadvertently created. However, there are some
However, when adding attributes to a namespace in a different file, the first step is to ensure that the namespace is already present and does not cause any damage to the existing namespaces. Can be implemented through a Non-destructive namespace
Write this mainly in order to solve some common web effects in JS parsing expected and the effect is different.
Original code:
Copy Code code as follows:
Test code
Window.onscroll = function () {
Alert ("haha");
}
Copy Code code as follows:
function Geturlmenucode () {
var url = window.location.href;
var parameter = url.substring (Url.indexof ('? ') + 1);
parameter = Parameter.split (' & ');
var reg =/menucode=/g;
var menucode = "";
for (var i = 0;
Keep it in your eyes!
Copy the blue code below to save the file in HTML format and use the Web browser to browse the effect
Code supports IE6, 7, 8/firefox/chrome browsers
Copy Code code as follows:
javascript Control div
Many pages will have a "back to the Top" button below, especially if there is no navigation at the bottom of the page, which will help visitors to find the navigation or revisit the ad (really beautiful). With the application of JavaScript in recent
I didn't expect the code to test successfully. ~ ~ is only ff below, modified to support IE. Because IE does not recognize function expressions.
Copy Code code as follows:
var iterator = function (fn) {
var coroutine = null;
var
1, to prevent the importation of backspace, excluding
Copy Code code as follows:
2. Limit input Maximum string length
Copy Code code as follows:
Limit Maximum input length
var Checkmaxl = function (length) {
var regc =/[^-
It is a very simple task to test the existence of a variable when writing a JavaScript program, but if you are not careful you will encounter some problems. There are several main points:
1. General variable
Copy Code code as follows:
First, the use of regular expressions to achieve startwith, endwith effect function
Copy Code code as follows:
String.prototype.startwith=function (str) {
var reg=new RegExp ("^" +str);
Return Reg.test (this);
}
Test OK,
Now in the browser, there is a very interesting feature, you can not refresh the page to modify the browser URL; In the browsing process. You can store your browsing history, and when you click the Back button in your browser, you can surf the
A comparison of all the dynamic plus methods
Copy Code code as follows:
/*
Dynamically loading JS v1.0 by:dum
Usage: src= "webjsbase.js?load=a,b"
Note: Load this directory under JS
*/
var webjsbase = {
Require:function (LibraryName)
Write it yourself, apply it, not too good, should also be able to optimize. Make a note of yourself first. No nonsense, the direct code to paste the best:
Copy Code code as follows:
/*
* Get time difference, the date format is year-month-
First type:
Copy Code code as follows:
The second type:
Copy Code code as follows:
The third type:
Copy Code code as follows:
The fourth kind:
Copy Code code as follows:
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