브라우저에 따른 처리방법
 
function xDOM(objectId, style) 
{
    if (stdDOM) return style ? document.getElementById(objectId).style  : document.getElementById(objectId);
    if (ieDOM)  return style ? document.all[objectId].style  : document.all[objectId];
    if (nsDOM)  return document.layers[objectId];
}
 
//new fcns added 03.04.06
function SetBackgroundColor(element, color)
{
    xDOM(element, 0).style.backgroundColor = color;
}

function DisplayOff(element)
{
    xDOM(element, 0).style.display = 'none';
}
 
 
gettyimage.com 에서 사용하고 있는 스크립트
/* Search_common.js - 12/27/05
 * General helper functions for scripts used in Search controls.
 *
 * Functions defined in other search js files depend on this file.
 *
*/
//03.03.06 X-browser DOM sniff...
var aDOM   = 0; 
var ieDOM  = 0;
var nsDOM  = 0;
var stdDOM = document.getElementById;

if (stdDOM) aDOM = 1; 
else 
{
    ieDOM = document.all; 
    if (ieDOM) aDOM = 1; 
    else 
    { 
        var nsDOM = ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) ==4)); 
        if (nsDOM) aDOM = 1; 
    }
}

//03.03.06: Encaps the DOM bidness...
function xDOM(objectId, style) 
{
    if (stdDOM) return style ? document.getElementById(objectId).style : document.getElementById(objectId);
    if (ieDOM)  return style ? document.all[objectId].style            : document.all[objectId];
    if (nsDOM)  return document.layers[objectId];
}
//new fcns added 03.04.06
function SetBackgroundColor(element, color)
{
    xDOM(element, 0).style.backgroundColor = color;
}

function DisplayOff(element)
{
    xDOM(element, 0).style.display = 'none';
}

// Do not allow the quick search flyout to popup before the body load event.
var g_ie6display = null; 
var g_ie6loaded = false; 
function IE6BodyLoad()
{
    g_ie6loaded = true;
    
    if (g_ie6display != null) 
    {
        IE6DisplayOn(g_ie6display);
    }
}
function IE6DisplayOn(element)
{
    if (!g_ie6loaded)
         g_ie6display = element
    else       
        xDOM(element, 0).style.display = 'block';
}

function DisplayOn(element)
{
    xDOM(element, 0).style.display = 'block';
}

function ToggleDisplay(element)
{
    e = xDOM(element, 0);
    e.style.display = (e.style.display == 'none') ? 'block' : 'none';
}
//new fcns added 03.04.06

function SetChecked(element, isChecked)
{
    xDOM(element, 0).checked = isChecked;
}

function WasChecked(element)
{
    return xDOM(element, 0).checked;
}

function swapBox(imgName) {    
	if (document.getElementById(imgName).src.indexOf("/images/arrow_right.gif") >-1) 
		document.getElementById(imgName).src = "/images/arrow_down.gif";
	else 
		document.getElementById(imgName).src = "/images/arrow_right.gif";
}

function swapCarrot(imgName) {    
	if (document.getElementById(imgName).src.indexOf("/images/arrow_right.gif") >-1)
		document.getElementById(imgName).src = "/images/arrow_down.gif";
	else
		document.getElementById(imgName).src = "/images/arrow_right.gif";
}

function imageSwap(imageElement, theSrc){
	imageElement.src = theSrc;
}

var g_isNav4 = false;
if (navigator.appName.toLowerCase() == "netscape")
	g_isNav4 = true;

// This nested If statement is necessary due to Navigator choking on e.keyCode.
function IsACR(e) {
	var retVal = false;
	if (g_isNav4)
	{
		if (e.which && (e.which == 13 || e.which == 3)) 
		{
			e.returnValue = false; // turn off event;
			retVal = true;
		} 
		else 
		{
			e.returnValue = e.keyCode;
		}
	}
	else 
	{
		if (e.keyCode && (e.keyCode == 13 || e.keyCode == 3))
		{
			event.returnValue = false; // turn off event;
			retVal = true;
		}	
		else 
		{
			event.returnValue = event.keyCode;
		}
	}
	
	return retVal;
}

function Trimmed(strInString)
{
	if (strInString == null)
		return "";
	
	var strOutString = "";
	for (var i = strInString.length-1; i >= 0; i--) {
		if (strInString.charAt(i) != ' ') {
			strOutString = strInString.substr(0, i+1)
			break;
		}
	}
	for (var i = 0; i < strOutString.length; i++) {
		if (strOutString.charAt(i) != ' ') {
			strOutString = strOutString.substr(i)
			break;
		}
	}
	return strOutString;
}

function CollapseNode(imagename, element)
{    
    swapCarrot(imagename);
    ToggleDisplay(element);
}

function gotSearchEnter(evt, ex, btn) 
{    
    if (!IsACR(evt)) 
        return false;
    var elCtrl = xDOM(btn, 0); 
    elCtrl.click();
    evt.cancelBubble=true; 
    return false;
}       


function CheckParentOption(ctrlChild, ctrlParent, excludedSection)
{
	var elChild = xDOM(ctrlChild, 0);
	var elParent = xDOM(ctrlParent, 0);
	if(elChild.checked)
	{
		SetChecked(ctrlParent, true);
	}

	if(excludedSection != '')
	{
		DisplayOff(excludedSection);
	}
}

function CheckChildOption(ctrlChild, ctrlParent, excludedSection)
{
	var elChild = xDOM(ctrlChild, 0);
	var elParent = xDOM(ctrlParent, 0);
	
	if(!elParent.checked)
	{
		SetChecked(ctrlChild, false);
	}
}

function CheckDropDownParent(ctrlParent, excludedSection)
{
	var elParent = xDOM(ctrlParent, 0);
	SetChecked(ctrlParent, true);
	if(excludedSection != '')
	{
		DisplayOff(excludedSection);
	}			
}

+ Recent posts