Javascript needing updated for ie8

I have the following javascript which works fine in IE7 but not in IE8. Inherited code and I'm a javascript novice, hence why i need the help. The code basically displays an overlayed div when a radio button list choice is selected. Code is actually run in an ASP.Net page.
// Get the position of an element
var x=0, y=0;
function getAbsElemPos(el) {
	var posX=0, posY=0;
	while (el!=null) {
		posX+=el.offsetLeft;
		posY+=el.offsetTop;
		el=el.offsetParent;
	}
	x=posX;
	y=posY;
}
//	
function eventDisplayWarning() {
    // set delay and only display if rb19 is default, only fire once
    setTimeout('closeMessage()',5000);
    var o=document.getElementById("msg");
    if (o) {
    	// make the message visible
        getAbsElemPos(document.getElementById("ctl00$phBody$rblQ18"));
    	o.style.top=y+'px';
    	o.style.left=x+'px';
		o.style.visibility='visible';
	} else {
		alert('Undefined message object');
	}
}
// Timeout functions
function closeMessage() {
    var o=document.getElementById("msg");
	if (o) {
		// hide the message
		o.style.visibility='hidden';
	} else {
		alert('Undefined message object');
	}
}
//
function eventDisplayWarningPause(e) {
	setTimeout('eventDisplayWarning()',350);
}
function insertElement(o) {
	// insert the msg div into the DOM
	var el='<div id="msg" class="bx"><p class="bxt">Please read the next question (Q19) and response options carefully.</p></div>';
	if (o && typeof HTMLElement!="undefined") {
		var r=o.ownerDocument.createRange();
		r.setStartBefore(o);
		var parsedHTML=r.createContextualFragment(el);
		o.parentNode.insertBefore(parsedHTML,o);
	} else {
		o.insertAdjacentHTML('beforeBegin',el);
	}
}
function connectEvents() {

    var fld = document.getElementsByName('ctl00$phBody$rblQ18');
	for (var i=0;i<fld.length;i++){

		if (i==1) { insertElement(fld[i]); } // choose a visible element as insertion point
		if (fld[i].addEventListener)
		{
		    fld[i].addEventListener('click',eventDisplayWarningPause,false);
		} else {
		    fld[i].attachEvent('onclick',eventDisplayWarningPause);
		}
	}
}


// run now
connectEvents();

Open in new window

suromaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Obadiah ChristopherCommented:
What exactly is the problem that u r facing. Is it the overlay div doesn't get displayed?

U'll have to provide some more code

getAbsElemPos(el)

Where is this function called from?

Which is the function called onclick of the radiobutton
0
suromaAuthor Commented:
eventDisplayWarningPause to added to the radiobutton click in connectEvents. The problem is that in IIS8 the overlay div is not displayed.

The proceedure just runs when the page loads - connectEvents
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.