spacer

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

home / experts / javascript / column76


Netscape 6, Part V: DOCJSLIB 1.1

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

The Library Code

<!--

// Copyright (c) 2001 internet.com Corporation.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Dr. Yehuda Shiran.

// Begin docjslib version 1.1. Released January 29, 2001.
// This is docjslib library. 
// It begins in this comment and continues until the matching comment, "End docjslib ...".
// It should not be normally touched. 
// docjslib is a cross-browser library. You should not worry about the browser in your code.
// This version includes the following functions:
//   getSrc (gets the image URL of an HTML element)
//   setSrc (sets the image URL of an HTML element)
//   makeImage (creates an HTML element)

var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var N6 = (document.getElementById && !document.all) ? true : false;

function getSrc(id) {
  if (NS4) {return eval("document." + id + ".document." + id + "img.src")}
  else if (IE4) {return eval("document.all." + id + "img.src")}
       else if (IE5 || N6) {return document.getElementById(id + "img").src};
}

function setSrc(id, url) {
  if (NS4) {eval("document." + id + ".document." + id + "img").src = url}
  else if (IE4) {eval("document.all." + id + "img").src = url}
       else if (IE5 || N6) {document.getElementById(id + "img").src = url};
}

function makeImage(imgID,          // given id
                   imgURL,         // image URL
                   imgHeight,      // image height
                   imgWidth,       // image width
                   imgAlt,         // alternative image
                   posFromLeft,    // absolute position from left of window
                   posFromTop,     // absolute position from top of window
                   clickParam1,    // parameter passed to "onclick" handler
                   clickParam2)    // parameter passed to "onclick" handler
  {
  document.write(
    '<STYLE TYPE="text/css">',
    '#', imgID, ' {',
      'position: absolute;',
      'left: ', posFromLeft, ';',
      'top: ', posFromTop, ';',
      'width: ', imgWidth, ';',
      'z-index: 1',
    '}',
    '</STYLE>',
    '<DIV ID="', imgID, '">',
    '<A HREF="javascript:', "handleImageClick('", imgID, "'", ',', clickParam1, ',', 
    clickParam2, ')">',
    '<IMG NAME="', imgID, 'img" ID="', imgID, 'img" SRC="', imgURL, '" ALT="', imgAlt, 
    '" BORDER="0" ', 'HEIGHT="', imgHeight, '" WIDTH="', imgWidth, '">',
    '</A></DIV>'
  );
}

//
// End docjslib Version 1.1
//

Next: A Final Word

http://www.internet.com

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


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: January 29, 2001
Revised: January 29, 2001

URL: http://www.webreference.com/js/column76/11.html