本文发表在 rolia.net 枫下论坛/******************************************************************************
* dhtmllib.js *
* *
* Copyright 1999 by Mike Hall. *
* Web address: http://www.brainjar.com *
* Last update: November 30, 1999. *
* *
* Provides basic functions for DHTML positioned elements which will work on *
* both Netscape Communicator and Internet Explorer browsers (version 4.0 and *
* up). *
******************************************************************************/
// Determine browser.
var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;
//-----------------------------------------------------------------------------
// Layer visibility.
//-----------------------------------------------------------------------------
function hideLayer(layer) {
if (isMinNS4)
layer.visibility = "hide";
if (isMinIE4)
layer.style.visibility = "hidden";
}
function showLayer(layer) {
if (isMinNS4)
layer.visibility = "show";
if (isMinIE4)
layer.style.visibility = "visible";
}
function isVisible(layer) {
if (isMinNS4 && layer.visibility == "show")
return(true);
if (isMinIE4 && layer.style.visibility == "visible")
return(true);
return(false);
}
//-----------------------------------------------------------------------------
// Layer positioning.
//-----------------------------------------------------------------------------
function moveLayerTo(layer, x, y) {
if (isMinNS4)
layer.moveTo(x, y);
if (isMinIE4) {
layer.style.left = x;
layer.style.top = y;
}
}
function moveLayerBy(layer, dx, dy) {
if (isMinNS4)
layer.moveBy(dx, dy);
if (isMinIE4) {
layer.style.pixelLeft += dx;
layer.style.pixelTop += dy;
}
}
function getzIndex(layer) {
if (isMinNS4)
return(layer.zIndex);
if (isMinIE4)
return(layer.style.zIndex);
return(-1);
}
function setzIndex(layer, z) {
if (isMinNS4)
layer.zIndex = z;
if (isMinIE4)
layer.style.zIndex = z;
}
//-----------------------------------------------------------------------------
// Window and page properties.
//-----------------------------------------------------------------------------
function getWindowWidth() {
if (isMinNS4)
return(window.innerWidth-6);
if (isMinIE4)
return(document.body.clientWidth);
return(-1);
}
function getPageWidth() {
if (isMinNS4)
return(document.width);
if (isMinIE4)
return(document.body.scrollWidth);
return(-1);
}
function getOffset()
{
var wid = getWindowWidth();
if (isMinNS4) {
if (wid <= 779) { return 0 ; }
if (wid > 779) { return (wid -779)/2-6 ; }
}
if (isMinIE4) {
if (wid <= 779) { return 0 ; }
if (wid > 779) { return (wid -779)/2 ; }
}
}更多精彩文章及讨论,请光临枫下论坛 rolia.net
* dhtmllib.js *
* *
* Copyright 1999 by Mike Hall. *
* Web address: http://www.brainjar.com *
* Last update: November 30, 1999. *
* *
* Provides basic functions for DHTML positioned elements which will work on *
* both Netscape Communicator and Internet Explorer browsers (version 4.0 and *
* up). *
******************************************************************************/
// Determine browser.
var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;
//-----------------------------------------------------------------------------
// Layer visibility.
//-----------------------------------------------------------------------------
function hideLayer(layer) {
if (isMinNS4)
layer.visibility = "hide";
if (isMinIE4)
layer.style.visibility = "hidden";
}
function showLayer(layer) {
if (isMinNS4)
layer.visibility = "show";
if (isMinIE4)
layer.style.visibility = "visible";
}
function isVisible(layer) {
if (isMinNS4 && layer.visibility == "show")
return(true);
if (isMinIE4 && layer.style.visibility == "visible")
return(true);
return(false);
}
//-----------------------------------------------------------------------------
// Layer positioning.
//-----------------------------------------------------------------------------
function moveLayerTo(layer, x, y) {
if (isMinNS4)
layer.moveTo(x, y);
if (isMinIE4) {
layer.style.left = x;
layer.style.top = y;
}
}
function moveLayerBy(layer, dx, dy) {
if (isMinNS4)
layer.moveBy(dx, dy);
if (isMinIE4) {
layer.style.pixelLeft += dx;
layer.style.pixelTop += dy;
}
}
function getzIndex(layer) {
if (isMinNS4)
return(layer.zIndex);
if (isMinIE4)
return(layer.style.zIndex);
return(-1);
}
function setzIndex(layer, z) {
if (isMinNS4)
layer.zIndex = z;
if (isMinIE4)
layer.style.zIndex = z;
}
//-----------------------------------------------------------------------------
// Window and page properties.
//-----------------------------------------------------------------------------
function getWindowWidth() {
if (isMinNS4)
return(window.innerWidth-6);
if (isMinIE4)
return(document.body.clientWidth);
return(-1);
}
function getPageWidth() {
if (isMinNS4)
return(document.width);
if (isMinIE4)
return(document.body.scrollWidth);
return(-1);
}
function getOffset()
{
var wid = getWindowWidth();
if (isMinNS4) {
if (wid <= 779) { return 0 ; }
if (wid > 779) { return (wid -779)/2-6 ; }
}
if (isMinIE4) {
if (wid <= 779) { return 0 ; }
if (wid > 779) { return (wid -779)/2 ; }
}
}更多精彩文章及讨论,请光临枫下论坛 rolia.net