Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird beahviour in IE setting display

Status
Not open for further replies.

GISHacker

Programmer
Nov 9, 2007
4
IE
Hi,

I am setting a div element visible using the following code
function showHelp()
{
var helpDiv = getRawObject('Help');
helpDiv.style.display = 'block';
}

It works fine in FF but in IE 7 it scrolls the page down to the div as if I was going to an anchor link.

Does anyone know why this my be happening

Thanks
 
Yep

function getRawObject(obj) {
var theObj;
if (typeof obj == "string") {
if (isW3C) {
theObj = document.getElementById(obj);
} else if (isIE4) {
theObj = document.all(obj);
} else if (isNN4) {
theObj = seekLayer(document, obj);
}
} else {
// pass through object reference
theObj = obj;
}
return theObj;
}

this.isW3C = (this.isCSS && document.getElementById) ? true : false;
 
FIXED!

I changed
<a href="#" onClick="showHelp();"><span>help</span></a>
to this
<a href="javascript:showHelp();"><span>help</span></a></span>
and it's fixed

Thanks
G'Hacker
 
Your getRawObject(obj) is totally unnecessary nowadays, unless you SPECIFICALLY need to be programming for browsers before Netscape 6 and IE 5.

Code:
var helpDiv = getRawObject('Help');
can be replaced with
Code:
var helpDiv = getElementById('Help');

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top