Mr_J Posted March 11, 2009 Share Posted March 11, 2009 Hi all, I just have a small issue, I want to add a little info POP UP when the user click on the image. I have tried various methods incl. asp etc. I have this nice "friend" texas web developers where I got the info from, but something is missing. 1st of all, it display the text on the main page instead of in the popup box and if I click the image(link) it brings the pop up to front but it show nothing [code ] <!-- POPUP Script --> <script language='javascript'> <!-- var twdPopupWindow=null; function twdPopup(mypage,myname,w,h,pos,infocus){ if(pos=='random'){ LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):200; TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):200;} if(pos=='center'){ LeftPosition=(screen.width)?(screen.width-w)/2:200; TopPosition=(screen.height)?(screen.height-h)/2:200;} else if((pos!='center' && pos!='random') || pos==null){LeftPosition=200;TopPosition=200;}settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,dependent=no'; twdPopupWindow=window.open('',myname,settings); if(infocus=='front'){twdPopupWindow.focus();twdPopupWindow.location='timedclose.asp';} } //--> </script> <!--POPUP Script END --> [/code] and the link of the image: <a href="javascript:twdPopup('timedclose.asp','twdPopup','250','400','','front');">text text text<img src=images/question.png></a> So I figured, I need timedclose.asp I have more code for the timedclose.asp <script language="JavaScript"> var TWDWindowCloseTimed = 3; function SetupWindowClose() { window.setTimeout("window.close()",TWDWindowCloseTimed*1000); } var TWDSafeOnload = new Array(); function TWDAddOnload(TWD) { isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false; IEmac = ((document.all)&&(isMac)) ? true : false; IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false; if (IEmac && IE4) { window.onload = SafeOnload; TWDSafeOnload[TWDSafeOnload.length] = TWD; } else if (window.onload) { if (window.onload != SafeOnload) { TWDSafeOnload[0] = window.onload; window.onload = SafeOnload; } TWDSafeOnload[TWDSafeOnload.length] = TWD; } else window.onload = TWD; } function SafeOnload() { for (var i=0;i<TWDSafeOnload.length;i++) TWDSafeOnload[i](); } TWDAddOnload(SetupWindowClose); </script> Please help... Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 11, 2009 Share Posted March 11, 2009 http://www.javascriptlint.com/online_lint.php if you still have problems let us know Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 11, 2009 Share Posted March 11, 2009 Fixed: var twdPopupWindow=null; function twdPopup(mypage,myname,w,h,pos,infocus){ if(pos=='random'){ LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):200; TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):200;} if(pos=='center'){ LeftPosition=(screen.width)?(screen.width-w)/2:200; TopPosition=(screen.height)?(screen.height-h)/2:200;} else if((pos!='center' && pos!='random') || pos===null){LeftPosition=200;TopPosition=200;}settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,dependent=no'; twdPopupWindow=window.open('',myname,settings); if(infocus=='front'){twdPopupWindow.focus();twdPopupWindow.location='timedclose.asp';} } Continued: var TWDWindowCloseTimed = 3; function SetupWindowClose() { window.setTimeout("window.close()",TWDWindowCloseTimed*1000); } var TWDSafeOnload = {}; function TWDAddOnload(TWD) { isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false; IEmac = ((document.all)&&(isMac)) ? true : false; IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE4.")!=-1)) ? true : false; if (IEmac && IE4) { window.onload = SafeOnload; TWDSafeOnload[TWDSafeOnload.length] = TWD; } else if (window.onload) { if (window.onload != SafeOnload) { TWDSafeOnload[0] = window.onload; window.onload = SafeOnload; } TWDSafeOnload[TWDSafeOnload.length] = TWD; } else{ window.onload = TWD; } } function SafeOnload() { for (var i=0;i<TWDSafeOnload.length;i++){ TWDSafeOnload[i](); } } TWDAddOnload(SetupWindowClose); Quote Link to comment Share on other sites More sharing options...
Mr_J Posted March 12, 2009 Author Share Posted March 12, 2009 Nice!! Thank you... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.