Solved

Pop up appears on absolute position on page

Posted on 2012-12-22
3
214 Views
Last Modified: 2012-12-24
Hi all,

I have a pop up and I want it to appear about 1/3 of the page down and to the left of the screen. Could someone give me an example of how to change the code to do this and I will then be able to play around with the exact coordinates. Here is the code for it that I need to alter:

<a href="#" onclick="Popup=window.open('http://www.r.com/module/r/template/default/controller/enq/questionpopup.php','Popup','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no, width=715,height=150,left=430,top=23'); return false;">

Open in new window

0
Comment
Question by:TLN_CANADA
  • 2
3 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 38716907
just play with the the left,top calculations to get exactly the position you want:


<a href="javascript:void(0);" onclick="PositionPopup('http://www.r.com/module/r/template/default/controller/enq/questionpopup.php', 'Popup',715,150); return false;">

 <script type="text/javascript">
							  function PositionPopup(pageURL, title,w,h) {
var left = (screen.width/6)-(w/6);
var top = (screen.height/6*5)-(h/6*5);
var targetWin = window.open (pageURL, title, 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no, width='+w+', height='+h+', top='+top+', left='+left);
} 
								  </script>

Open in new window

0
 

Author Comment

by:TLN_CANADA
ID: 38717496
Thanks! That's working perfectly now. One other small question about this if I may.

I have no different pop ups on the page that I want the user to be able to use both or separately as they wish.

Here is the code for the new popups:

			<a href="#" onclick="Popup=window.open('http://www.xxxx.com/','Popup','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no, width=600,height=490,left='+(screen.width-600)+',top=0'); return false;"><img src="res/imer.png"></a>
			
			<a href="javascript:void(0);" onclick="PositionPopup('http://www.xxdfdx.com/module/x/template/default/controller/enq/questionpopup.php', 'Popup',715,150); return false;"><img src="res/generate_question.png"></a>

Open in new window


At the moment when I open both pop ups the second one overrides the first one but I want them to appear in separate popup windows.

Thanks for your help,

Derek
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38718025
you have to use unique name for each popup to prevent overriding (since both windows called 'Popup')
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now