Bookmarking Pages with JavaScript

Internet Explorer Only Sorry folks, that's life! This can only be done in Microsoft Internet Explorer. In this example we only show the bookmark link if the browser is Internet Explorer. The Example <script type="text/javascript"> <!-- if (document.all) { document.write("<a href="javascript:window.external.AddFavorite(location.href, 'Bookmarking with JavaScri...

Posted in JavaScript at 2005-09-26T21:04:29Z.

Talk to JavaScript with Java

Communication between JavaScript and Java applets can be made possible using something called LiveConnect. JavaScript can be used to access Java variables, classes and methods directly, and conversely Java can be used to access JavaScript methods and properties. Enabling LiveConnect Before Java and JavaScript can communicate at all, LiveConnect must be enabled. This is done by putting a special...

Posted in JavaScript Java at 2005-10-23T05:41:38Z.

Cookies in JavaScript

This tutorial should get you started with cookies in JavaScript. Some utility JavaScript functions are included for you to use freely in your own code. JavaScript cookies are easily manipulated using the document.cookie property. Setting Cookies To set a cookie all we need to do is assign a value to the document.cookie property. document.cookie = "name=value"; Retrieving Cookies Reading c...

Posted in JavaScript at 2005-11-16T23:13:45Z.

Rollovers with JavaScript

Move your mouse over the image below. It should change. This is called a "rollover" or a "hover button." JavaScript is used with two images to make an image link change when a mouse moves over it. JavaScript Code Here is the JavaScript code for the example above: <script type="text/javascript"> <!-- if (document.images) { image_off = new Image(295, 106); image_off...

Posted in JavaScript at 2005-11-16T23:39:56Z.

Escaping Frames with JavaScript

Some Web sites may try and display your pages in one of their own frames, so they can bombard the user with adverts as they try to surf your site. Moreover, by putting your page in a frame users will be unable to bookmark your pages properly. We can use a very simple piece of JavaScript to ensure that a page is not shown inside a frame. <script type="text/javascript"> <!-- if (...

Posted in JavaScript at 2005-11-16T23:44:37Z.

Preloading Images with JavaScript

Preloading images is when images are loaded into the browser's cache so that when they are needed they are displayed immediately. This is often done in JavaScript rollover effects. Using JavaScript, images can be loaded into the browser's cache with the Image object. Here is an example script that preloads three images: <script type="text/javascript"> <!-- if (document.images) ...

Posted in JavaScript at 2005-11-17T10:23:44Z.

Stopping Right-clicks with JavaScript

Of course, there isn't really any way to stop users from clicking on your pictures or viewing the source code of your frames, but this little bit of code makes it a good deal harder to right-click. Try right-clicking on this page. This trick only works with the latest browsers (4.x and higher). As the great Leonardo da Vinci once said, bad artists copy, good artists steal :-) JavaScript Code ...

Posted in JavaScript at 2005-11-17T21:16:56Z.