PDA

View Full Version : popup windows in wrong location



RTFM
Mar 1st, 2007, 01:48 PM
Let me explain first a bit.

I am using a javascript that pops up a window in the face of a visitor. Live Chat type of thing. This window is activated remotely.

When called upon it should pop up in the face of the visitor, no matter how far down they scrolled, but it only shows on top of the page. It seems to be locked by the div's on the page.

My site is built using css with quite a few divs on the page.

The invitescreen is activated by a script that is pasted on my html just before the </body> tag.

When I activate the invite, it pops up at the top of the first div, rather than in the face of the visitor.

As a result the invite screen only shows on the upper top of the page. So if the visitor is already past there, they will never see the invitation for the live chat.

I am posting the script below that guides the positioning of the invite-screen.

------------------ script myinvite.js --------------------------


var locX=0;
var locY=250;
var imgW=0;
var maxX=0;
var getC=0;
var docW=document.body.clientWidth;
var hldX=0;
var incX=1;
var cStat=1;
imgPoll=new Image();
imgPoll.onload=chkImg;
document.write('<div name="woInvite" id="woInvite" style="style="position: absolute; top:250; left: 0; z-index: 999">');
document.write('&nbsp;</div>');
setTimeout("getImg()",1000);
function woMove(){
if(hldX==0){
newX=locX+incX;
if(incX>0){
if(newX<maxX){
locX=newX;woDIVs.left=locX;
setTimeout('woMove()',12);
} else {
incX=-1;
setTimeout('woMove()',1000);
}
} else {
if(locX>0){
locX=newX;woDIVs.left=locX;
setTimeout('woMove()',6);
} else {
setTimeout('stopInvite()',4000);
}
}
}
}
function getImg(){
var rTimer=5000;
if(cStat==1){
var pUrl="http://213.206.91.13:8080/poll.gif?domain=www.beatingbackpain.com&stamp="+(new Date()).getTime();
if(typeof(sSession)!="undefined"){pUrl+="&u="+sSession;}
imgPoll.src=pUrl;
}
getC++;
if(getC>6)rTimer=10000;
if(getC>20)rTimer=15000;
if(getC>30)rTimer=0;
if(rTimer>0)setTimeout("getImg()",rTimer);
}
function chkImg(){
if(imgPoll!=null){
nStat=imgPoll.width;
if(nStat!=cStat){
cStat=nStat;
if(cStat==3)startChat();
if(cStat==2)startInvite();
if(cStat==1)stopInvite();
}
}
}
function getIImgw(){
imgW=woIMG.width;maxX=docW-imgW;
}
function startInvite(){
var ofsY;
ofsY=document.body.scrollTop;
hldX=0;incX=1;locX=0;locY=250;
woDIVs=document.getElementById('woInvite').style;
woDIVh=document.getElementById('woInvite');
woDIVh.innerHTML='<a href="javascript:void(0);" onclick="return startChat(event);" onMouseOver="anPause()" onMouseOut="anResume()"><img border="0" src="http://213.206.91.13:8080/invite.gif?domain=www.beatingbackpain.com&stamp='+(new Date()).getTime()+'" name="woIImg"</a>';
woDIVs.top=locY+ofsY;woDIVs.left=locX;
setTimeout('woMove()',3000);
woIMG=document.images.woIImg;
woIMG.onload=getIImgw;
}
function stopInvite(){
cStat=1;woDIVh.innerHTML="";
setTimeout("getImg()",10000);
}
function startChat(event){
clsX=locX+imgW-12;
clsY=locY+12;
if(event.clientX<clsX || event.clientY>clsY){
this.chatWindow=window.open("http://213.206.91.13/chat/chatstart.htm?domain=www.beatingbackpain.com","Chat","width=484,height=361");
this.chatWindow.focus();this.chatWindow.opener=window;
}
stopInvite();
}
function anPause(){
hldX=1;
}
function anResume(){
hldX=0;
setTimeout('woMove()',1000);
}