spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

JavaScript Tip of the Week for September 16, 1996: JavaScript and Java

One of the most useful things in LiveConnect is the way it allows JavaScript to interact with Java. You now have ability to access Java's methods and classes through JavaScript. Using this LiveConnect feature with Java, I can tell that your Using that information, I can then create a horizontal rule that fits the width of your screen.
Detecting the screen size and then changing the look of the page to fit that size is actually an easy task. First, call the java classes that allow you to determine the screen size:
    if (navigator.javaEnabled()) <-- determine if java is enabled
    {
    var toolkit = java.awt.Toolkit.getDefaultToolkit();
    var screen_size = toolkit.getScreenSize();       
    width = screen_size.width; 
    height = screen_size.height;
    }
This code takes Java's getScreenSize() function gives it value to variable screen_size. Then the height and width properties of screen_size are given to variabes height and width, respectively, for ease of use. Finally, using the new JavaScript evaluation feature, a horizontal rule the 35 pixels less than width of the screen is created:
    <IMG SRC = "rule.gif" HEIGHT = 9 WIDTH = "&{width - 35};">

This is just the tip of the iceberg, in the future, there will be tips that deal with Java, JavaScript, and Plug-ins together in harmony. (What a nice thought, isn't it?)

Source

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business