homepage Welcome to WebmasterWorld Guest from 54.226.180.223
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Popup window - how to center content into popup window
popup
mladja04




msg:3995771
 5:14 pm on Sep 25, 2009 (gmt 0)

Hello,

Please, can someone tell me how I can (if I can), when open popup window after user click in link - new window to be with some specified dimension, but content of page which is in window to start from some line which I will define?
Do that is possible?

Thank you very much, Mladen

 

rocknbil




msg:3996339
 7:10 pm on Sep 26, 2009 (gmt 0)

Welcome aboard mladja04, if your pop up is an external resource or static web page, you can center content by including CSS or a link to external CSS in the head.

<style type="text/css">
#main { width: 95%;, margin: auto; }
</style>

or

<link rel="stylesheet" type="text/css" href="mystyle.css">

If it's written out with document.write, you can do the same:

document.write('<link rel="stylesheet" type="text/css" href="mystyle.css">');

If you mean center the pop up in the viewport, you will probably have to get the viewport's parameters (width, height, etc.) first with Javascript, then do some math to position it in the center of the viewport. No code immediately handy, but a search for Javascript Window Object should turn up some results. Note that Moz browsers and IE have different ways of getting these.

mladja04




msg:3996367
 8:21 pm on Sep 26, 2009 (gmt 0)

Thank you for reply. I need to open external page in popup window and want to know do I can to specify start row in that new page.
This is code which I use (example):

<!-- TWO STEPS TO INSTALL POPUP WINDOW:

1. Paste the first into the HEAD of your HTML document
2. Use the code to open the popup page on your site -->

<!-- STEP ONE: Copy this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Idea by: Nic Wolfe -->
<!-- This script and many more are available free online at -->

<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=600');");
}
// End -->
</script>

<!-- STEP TWO: Use the following link to open the new window -->

<A HREF="javascript:popUp('http://www.mysite.com')">Open the Popup Window</A>

<!-- Script Size: 0.73 KB -->

Do it possible to I make what I need?

Thank you very much again.
Mladen

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved