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.
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.