JavaScript FAQ (23)--bookmarklet

Source: Internet
Author: User

20, Bookmarklet

1, what is bookmarklet. (What ' s a bookmarklet?)

Q: what is bookmarklet.

A: Bookmarklet is a small piece of JavaScript program that is all included in the hyperlink URL. (JavaScript URLs are like this: <a href= "Javascript:the code goes Here" >. Most browsers allow users to add these JavaScript url bookmarks just as they would add other hyperlinks. The word bookmarklet was created by Steve Kanga, who also developed a number of useful bookmarklet himself. The following is a simple example: back bookmarklet.

Go-back bookmarklet

This bookmarklet is equivalent to the browser's Back button. Click on the title above to preview its effect. Right-click on the title, choose to add a bookmark (according to the browser) or add it to your favorites , and add it to your bookmarks.

2, Bookmarklets: Browser support (Bookmarklets:browser Support)

Q: those browsers support Bookmarklets.

A: The following browsers support Bookmarklet:netscape Navigator 3.0 and newer versions of Internet Explorer 4.0 and newer versions

Not all bookmarklet can work correctly in any browser. This is because different browsers have different implementations of JavaScript. To write a cross-browser bookmarklet: Use a JavaScript subset supported by all target browsers. Make sure the bookmarklet code is not too long.

3, Bookmarklet: Maximum Length (bookmarklet:maximum)

Q: What is the maximum length of the bookmarklet code?

A: The maximum length of the bookmarklet code varies depending on the browser.

Experiments have shown that the most stringent requirements are in ie6.x. Any bookmarklet with a code length of 510 may have no way of working properly in IE6.

4, Calculator bookmarklet (Calculator bookmarklet)

Q: can I have a calculator in my bookmarks?

A: Yes, this is a Calculator bookmarklet.

Click on the link above to preview its effect. To turn off the calculator, simply click the Cancel button above it. To add this calculator to your bookmarks, right-click on the hyperlink, and then choose Add Bookmarks or favorites (depending on the browser).

This bookmarklet is tested in NS4 and MSIE4.

5, Clock Bookmarlet (Clock bookmarklet)

Q: can I have a clock in the bookmark?

A: Yes, this is a clock bookmarklet.

This is where the clock will display your browser's status bar. Click on the link above to preview its effect. To add this clock to your bookmarks, right-click on the hyperlink, and then choose Add Bookmarks or favorites (depending on the browser).

This bookmarklet is tested in msie4+, Firefox1.5, and ns4+.

6. JavaScript interpreter bookmarklet (JavaScript interpreter bookmarklet)

Q: can I create a bookmarklet that contains the JavaScript interpreter.

A: of course you can. In fact, some JS programmers find JavaScript interpreter bookmarklet very useful. Not only is it possible to execute a line of JavaScript code directly, it can also check the status of any variable in the code while viewing the HTML page. Here is a JavaScript interpreter bookmarklet.

Click the link above to get the JavaScript interpreter input box. Enter the JS variable name and check its status. Enter a line of code to execute it. Click the Cancel button on the input box to exit the interpreter input box. To add this JavaScript interpreter to your bookmarks, right-click on the hyperlink, and then choose Add Bookmarks or favorites (depending on the browser).

This bookmarklet was tested on NS4 and MSIE4.

Related Article

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.