JS skills you may not know

Source: Internet
Author: User
JS skills you may not know)

1. document. getelementsbytagname can be used to obtain all elements of a tag. getelementsbytagname ('*') obtains all elements on the page. The asterisk represents any tag, and the tagname of the annotation tag is "!"

2. Differences between the string method substr and substring
Substr (start [, length]) indicates that length strings are obtained from the start position.
Substring (START, end) indicates a string from start to end, including the start position but not the end position.

3. "=" and "="
The former compares two objects and automatically performs type conversion. For example, if '12' = 12 is compared, true is returned. If the latter does not perform any conversion, it must be completely equal to '12' = 12, and false is returned.

4. How to Make webpages unavailable
<NoScript> <IFRAME src = *. html> </iframe> </NoScript>

5. Use document. Referrer to obtain the address of the previous page.

6. Use the form attribute of the input element to obtain the form element to which the input belongs.

7. Defer attribute in the script tag
The function is to tell the browser that HTML can be executed, instead of executing the JS Code specified by Src until the execution fails.

8. arguments can be used to obtain an array of all parameters passed to the currently executed function, even if you have not defined any parameters for the function.

9. You can use document. Anchors to obtain all the link elements on the page without using document. getelementsbytagname ('A'). Likewise, document. Forms, document. Images

10. Use js to determine whether the. NET Framework is installed on the client.
Function hasdotnetframework () {return navigator. useragent. indexof (". Net CLR")>-1 ;}

11. Use & quot; instead of "" in client events
For example, VAR html = '<a href = "javascript: Alert (& quot; this is message & quot;)"> Hello </a>'

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.