Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

A Cross Browser Dictionary

January 19, 1999

A "translation dictionary", bridging the DHTML syntax gap between browsers.
function crossBrowser()
{ if (document.all)
  //Microsoft syntax
  { obj			= "document.all";
    innerLayersLength	= ".children.length";
	innerLayer	= ".children";
	posLeft		= ".style.pixelLeft";
	posTop		= ".style.pixelTop";
	posWidth  	= ".clientWidth";
	posHeight  	= ".style.pixelHeight";
	posHeight2 	= ".clientHeight";
	bgColor		= ".style.backgroundColor";
	visibility	= ".style.visibility";
	visible		= "='visible'";
	visible_eng	= "visible";
	invisible  	= "='hidden'";
	invisible_eng	= "invisible";
    startItemDiv    	= "<div class=\"item\"
	onMouseOver	=\"this.style.backgroundColor='"+
	 menuHIGH+"';\"
	 onMouseOut	=\"this.style.backgroundColor='"+
	 menuBGCOLOR+"';\">";
	headlineDiv	="<div class=\"headline\">";
	closeItemDiv	="</div>";
	  
  }
  else
  //Netscape syntax
  { obj			= "document.layers";
    innerLayersLength	= ".document.layers.length";
    innerLayer		= ".document.layers";
	posLeft		= ".left";
	posTop		= ".top";
	posWidth   	= ".clip.width";
	posHeight  	= ".clip.height";
	posHeight2	= ".clip.height";
	bgColor		= ".bgColor";
	visibility	= ".visibility";
	visible		= "='show'";
	visible_eng	= "show";
	invisible  	= "='hide'";
	invisible_eng	= "hide";
	startItemDiv	= "<layer id=\"itemlayer\" left=0
	onMouseOver	=\"this.bgColor='"+
     menuHIGH+"';clearTimeout(opener.clearPop);\"
 	onMouseOut	=\"this.bgColor='"+
     menuBGCOLOR+"';\"
	 bgcolor	=\""+menuBGCOLOR+"\">";
	headlineDiv	= "<layer id=\"headlinelayer\"
	 left		= 0
	 width		= 250
	 position	=\"absolute\" 
    z-index		= 1 bgcolor=\""+headBGCOLOR+"\">";
    closeItemDiv	= "</layer>";
	
  }
}

The crossBrowser() function appears ominous at first but it is actually quite amiable. This function serves to bridge the syntactical gap between DHTML support in Navigator 4 and Internet Explorer 4. Thought of as a translation dictionary of sorts, this function defines a set of standard variable names, such as obj, and defines them through their literal meaning in each browser. So, for example, while one refers to a layer object in Internet Explorer via the reference "document.all", one would refer to a layer in Netscape using "document.layers".

Using this approach, we will simply substitute the term obj when needing to reference a layer, as you will soon see, sidestepping the syntax squabble. The key to this trick will be the JavaScript eval() function. This function accepts a string parameter and it executes the value of the string as a JavaScript statement. For example, imagine that we've defined a variable named closeme thusly:

closeme="self.close()";

The following statement, then, would be the functional equivalent of "self.close()":

eval(closeme);

In any case, the crossBrowser() function simply defines the translations ... shortly, we'll see them used in action.

Creating the menu arrays and global color values
DHTML Pop-Up Menus: A Parable of Triumph and Loss (Based on a True Story)
Internet Explorer 4 mouse events


Up to => Home / Authoring / DHTML / Menus




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers