JavaScript Tutorials - Herong's Tutorial Examples - 2.33, by Herong Yang
'javascript:' Pseudo-URL Addresses
This section describes what is a 'javascript:' pseudo-URL address and provides several interesting examples of 'javascript:' URLs.
Many Web browsers also support "javascript:" pseudo-URL addresses in the form of:
javascript:statement;statement;...
When a "javascript:" pseudo-URL is given to a browser, it will start to evaluate those JavaScript statements included in the URL. Here are some examples of "javascript:" pseudo-URL addresses that you can try:
1. The following URL will cause the browser to display a text message in small dialog box.
javascript:alert("Hello World!");
2. The following URL will cause the browser to display a new page with a text message.
javascript:document.write("<html><body>Hello World!</body></html>");
3. The following URL will cause the browser to execute a complex JavaScript code resulting a HTML page with prime numbers. Note that the entire URL address must be written in a single line. So you need to join those lines below, copy and paste it to a browser.
javascript:var i, j, is_prime; document.write('<body><pre>'); for ( i=3; i<=30; i+=2 ) { is_prime = true; for ( j=2; j<=i/2; j++) { is_prime = i%j > 0; if (!is_prime) break;} if (is_prime) document.writeln('Found a prime number: ' + i); } document.write('</pre></body>');
Now it's your turn to write more "javascript:" URL examples.
Table of Contents
ECMAScript Language Specification and JavaScript Dialects
Data Types, Variables and Expressions
Creating, Accessing, and Manipulating Arrays
Defining and Calling Functions
►Web Browser Supporting JavaScript
JavaScript Support in Web Browsers
Including JavaScript Codes with HTML "script" Tags
type="text/javascript" or language="JavaScript"
JavaScript Version Supported by Browsers
Including 'script' Tags in String Literals
Escaping 'script' Tags in String Literals
Using HTML Entities to Protect HTML Tags
Including JavaScript Codes as External Files
DOM API - The "document" Object
DOM API - The "window.open" Method
►'javascript:' Pseudo-URL Addresses
JavaScript Console in Google Chrome
JavaScript Console in Mozilla Firefox
JavaScript Console in Apple Safari
JavaScript Console in IE (Internet Explorer)
Server-Side and Client-Side Web Scripting
Defining Your Own Object Types
Inheritance of Properties and Methods through the Prototype Object Chain
'jrunscript' - JavaScript Shell Command from JDK
Using Functions as "Function" Objects
Introduction to Built-in Object Types
W3C's Document Object Model (DOM) Specifications