20. bookmarklet
1. What is bookmarklet? (What's a bookmarklet ?)
Q:What is bookmarklet?
A:Bookmarklet is a small JavaScript program that is included in the hyperlink URL. (Javascript URL is like this: <a href = "javascript: the code goes here"> .) Most browsers allow users to add these javascript URL bookmarks, just like adding other hyperlinks. The word bookmarklet was created by Steve Kanga and he has developed many useful bookmarklet. The following is a simple example: bookmarklet.
Go-back bookmarklet
This bookmarklet is equivalent to the browser's back button. Click the title above to preview the effect. Right-click the title and select (based on the browser)Add bookmarksOrAdd to favoritesYou can add it to your bookmarks.
2. bookmarklets: browser support (bookmarklets: browser Support)
Q:Which browsers support bookmarklets?
A:The following browsers support bookmarklet:
Netscape Navigator 3.0 and later versions
Internet Explorer 4.0 and later versions
Not all bookmarklets can work normally in any browser. This is because different browsers have different implementations for JavaScript. To write a cross-browser bookmarklet:
- Use the Javascript subsets supported by all target browsers.
- Make sure that the bookmarklet code is not too long.
3. bookmarklet: Maximum length (bookmarklet: Maximum length)
Q:What is the maximum length of the bookmarklet code?
A:The maximum length of the bookmarklet Code varies with the browser.
Experiments show that the strictest requirement is in ie6.x. Any bookmarklet with a code length of 510 may not work 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 the link above to preview the effect. To close the calculator, just clickCancelButton. To add this calculator to your bookmarks, right-click the hyperlink and selectAdd bookmarksOrAdd to favorites.
The bookmarklet passed the test in ns4 and msie4.
5. Clock bookmarlet (clock bookmarklet)
Q:Can I have a clock in my bookmarks?
A:Yes. This is a clock bookmarklet.
The clock will display on the status bar of your browser. Click the link above to preview the effect. To add the clock to your bookmarks, right-click the hyperlink and selectAdd bookmarksOrAdd to favorites.
The bookmarklet was tested in msie4 +, firefox1.5, and ns4 +.
6. javascript interpreter bookmarklet (javascript interpreter bookmarklet)
Q:Can I create a bookmarklet containing a javascript interpreter?
A:Of course. In fact, some JavaScript programmers have found that the javascript interpreter bookmarklet is very useful. It is not only because it can directly execute a line of JavaScript code, it can also check the status of any variable in the code when viewing the HTML page. Here is a javascript interpreter bookmarklet.
Click the link above to obtain the javascript interpreter input box.
Enter the JS variable name and check its status.
Enter a line of code and execute it.
ClickCancelButton to exit the interpreter input box.
To add this javascript interpreter to your bookmarks, right-click the hyperlink and selectAdd bookmarksOrAdd to favorites.
The bookmarklet passed the test on ns4 and msie4.