overlay div pop up not working in google chrome

Okay, here is the issue and solution

Problem: i found a java script across internet for div pop up using overlay, working fine with all browsers except chrome. In chrome it would execute to create a popup but its position was top left of the screen and was viewable less than 50%.

Solutions: here is the solution.

if (!window.ie6) {
this.overlay.setStyles({
position: ‘fixed’,
top: 0,
left: 0
});
this.window.setStyles({
position: ‘fixed’,
top: ’50%’,
left: ’50%’
});
} else if (navigator.userAgent.indexOf(‘Chrome’) !=1) {

this.overlay.setStyles({
position: ‘absolute’,
top: ’0%’,
left: ’0%’
//,marginTop: “expression(document.documentElement.scrollTop + ‘px’)”
});

this.window.setStyles({
position: ‘absolute’,
top: ’50%’,
left: ’50%’
//,marginTop: “(expression(0 – parseInt(this.offsetHeight / 2) + document.documentElement.scrollTop + ‘px’)”
});

}else {
this.overlay.style.setExpression(‘marginTop’, ‘document.documentElement.scrollTop + “px”‘);
this.window.style.setExpression(‘marginTop’, ’0 – parseInt(this.offsetHeight / 2) + document.documentElement.scrollTop + “px”‘);

this.overlay.setStyles({
position: ‘absolute’,
top: ’0%’,
left: ’0%’
//,marginTop: “expression(document.documentElement.scrollTop + ‘px’)”
});

this.window.setStyles({
position: ‘absolute’,
top: ’0%’,
left: ’0%’
//,marginTop: “(expression(0 – parseInt(this.offsetHeight / 2) + document.documentElement.scrollTop + ‘px’)”
});
}

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s