6. Writing Method of prototype. js
CopyCode The Code is as follows: // the code in prototype. js
VaR class = {
Create: function (){
Return function (){
This. Initialize. Apply (this, arguments );
}
}
}
// Simplified
Function clazz (){
Return
Number of rows Number of columns Number of images time seconds Reset
[Ctrl + A select all Note: If you need to introduce external JS, You need to refresh it to execute]
CodeListing 1-1 shows an example of the variable scope of JavaScript.
// Set the global variable Foo to "test"
VaR Foo = "test ";
// In the if Block
If (true ){
// Set Foo to 'new Test'
VaR Foo = "new test ";
}
// As we can see, foo is now
As follows:
CopyCode The Code is as follows: function checkattachment (){
Alert ("here ");
VaR attachmentarray = Document. getelementsbytagname ("input ");
VaR attachmentsizearray = Document. getelementsbyname ("filemaxsize ");
VaR Index = 0;
For
CopyCodeThe Code is as follows:
') ">
When the value extracted from bean is single quotes, a JS error will be reported when loading the page. You can use the following method to solve the problem.Copy codeThe Code is as follows: "/>
Function
1. Put the definition of the number of cycles in the external body of the Loop: It seems that all languages are the same, and the effect on more than 100 elements is becoming more and more obvious. That is to say, for (VAR I = 0; I = 0; I --).
1. Replace () Example:
2. Search ()
Example:
3. Slice () selects a part of the string to generate a new string
Example:
4. Match () searches for the specified value from the string. It returns the specified value instead of the position
Weak JavaScript does not followProgramFrom the actual variable type to the required data type conversion, for example, a very common error, in the browser script, obtain the sum of one numeric variable to be input and another numeric variable from
There is no such object in Firefox. If function nested calls exist, the event must be continuously passed down, for example, in the following scenario.
CopyCode The Code is as follows:
Function Test (event, DOM ){
Test1 (event );
}
Function test1
Recently, due to project requirements, if the image is larger than 100x100, it is reduced to 100x100. If the image is smaller than this, the original image size is kept. After research, we found that javascript can be used
CodeSimple implementation.
1.Extjs treepanels
TreepanelsIt is a tree control used by extjs itself. It is one of the best tree controls currently. It has many advantages, such as support for free drag-and-drop, and extjs itself has very well-developed APIs and development
Solution 1:
Windows Shell is called, but security issues may occur.
* Browsefolder. js* This file defines the browsefolder () function, which provides a folder selection dialog box.* Allows you to select system folders.* The start directory of
9. Yui Writing Method
Yui 2.7.0 is introduced here. You only need to introduce Yahoo. js. Yui introduces namespaces, similar to Java packages. The following Yahoo tool function package
Yahoo. namespace
Yahoo. Lang
Yahoo. Lang.
A problem occurs when a page is displayed. In many cases, the displayed text needs to be folded, for example, the text exceeds the width of TD or the width of Div.Word-break is available in IE, but it does not work in ff. So I studied it and wrote a
How to refresh the page with javascript:
CopyCode The Code is as follows: 1 history. Go (0)
2 location. Reload ()
3 location = Location
4 location. Assign (location)
5 document.exe ccommand ('refresh ')
6 window. navigate (location)
7 location.
1. Objects in Javascript
Javascript is an object-based
Programming Language Why is it based on objects rather than object-oriented, because JavaScript itself only implements encapsulation without inheritance and polymorphism. Since it is
Function begindrag (elementtodrag, event)
{
Var = event. clientx-parseint (elementtodrag. style. Left );
VaR deltay = event. clienty-parseint (elementtodrag. style. Top );
// Here, deltax/Y is actually the Coordinate Difference Between the mouse and
Javascript parsing reads XML files, mainly load and parse XML files, and then you can test the content of the parsed XML file and print the output.
Online Demo: http://demo.jb51.net/js/2012/readxml/
Note: during the test, you need to test on 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