Is the "javascript: function ()" URL?

Looking through the WebView demo , I noticed the following statement:

  mWebView.loadUrl("javascript:wave()");

This works, but I do not understand the syntax. Why does "javascript: function ()" work as a URL parameter for WebView.loadUrl ()?

+3
source share
5 answers

This is called a Bookmarklet .

Here are some examples: http://www.bookmarklets.com/

0
source

Yes, although not very far along the standards path: http://tools.ietf.org/html/draft-hoehrmann-javascript-scheme-03

The return value of the function must be a visualized document.

+2

, <a href="javascript:alert('test')">link text</a> , javascript .

+1

Yes, this is a URL that defines some javascript functions that will execute in the global area of ​​the current page.

This works bookmarklets

+1
source

If you know the concept of "overloading" something, think about it. The browser is designed to check the string that you put in the address bar (or pass it as href), and if it starts with the string literal "javascript:", it knows how to execute javascript, and not treat it as a URL,

+1
source

All Articles