Advertisement

11.16.2003 at 06:08PM PST, ID: 20799883
[x]
Attachment Details

CENTER POPUP WINDOW ON TOP ACCORDING TO BROWSER SIZE AND POSITION NOT TO SCREEN SIZE

Asked by Pollin in JavaScript

Tags: , , ,

Hello guys:

I need a function to CENTER a popup window according the BROWSER SIZE AND POSITION AND STAYS ON TOP. Also, the function must work without passing the width and height parameters from the picture, because the only parameters that must past to the function is the picture's URL and windows title. Maybe the function should be possible to calculate itself the picture's width and height.

There are a lot of solutions that centers a popup window in the screen with the window.open parameters, but they need the picture size.

The code that I have works with the screen size. I need that the Popuppic function centers the popup according the BROWSER size and doesn´t need to receive the width and height parameters of the picture and the popup window must stay on top.

The opener file is:
  //INDEX.HTML

function PopupPic(sPicURL, title,w,h) {
     var winl = (screen.width - w) / 2;
     var wint = (screen.height - h) / 2;
     winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+'resizable=0'
   window.open("picturedetail.html?"+sPicURL+"&"+title+"", "", winprops)
   }

The popup file is:    

//picturedetail.html    /receives a query string with the url

<HTML>
<HEAD>
<script language='javascript'>
function FitPic() {
       iWidth = (NS)?window.innerWidth:document.body.clientWidth;
       iHeight = (NS)?window.innerHeight:document.body.clientHeight;
       iWidth = document.images[0].width - iWidth;
       iHeight = document.images[0].height - iHeight;
       window.resizeBy(iWidth, iHeight);
       self.focus();
       }
</SCRIPT>
</HEAD>

<BODY onload='FitPic();' topmargin="0" marginheight="0" leftmargin="0"  
                                      marginwidth="0">

<script language='javascript'>
      document.write( "<img src='" + picUrl + "' border=0>" );
</script>

</BODY>
</HTML>


Best Regards

PollitoStart Free Trial
 
 
[+][-]11.16.2003 at 06:36PM PST, ID: 9761097

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2003 at 08:16PM PST, ID: 9761402

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.17.2003 at 01:17PM PST, ID: 9766947

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.17.2003 at 01:55PM PST, ID: 9767212

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.17.2003 at 02:51PM PST, ID: 9767603

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.18.2003 at 12:54AM PST, ID: 9769670

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.18.2003 at 04:16AM PST, ID: 9770405

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.20.2003 at 04:10PM PST, ID: 9792021

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.20.2003 at 04:18PM PST, ID: 9792045

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.20.2003 at 04:22PM PST, ID: 9792053

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Tags: center, javascript, window, popup
Sign Up Now!
Solution Provided By: devic
Participating Experts: 1
Solution Grade: B
 
 
[+][-]11.20.2003 at 04:32PM PST, ID: 9792096

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32