Solved

Code for popping up quarter-page brower windows

Posted on 2000-05-03
6
178 Views
Last Modified: 2010-04-09
I am looking for the html code (and basic instructions) that will pop a url into a new, quarter page browser window. I know that  <target =" _blank"> pops up a new window, but what about a new, quarter page window?
0
Comment
Question by:scupps
6 Comments
 
LVL 4

Expert Comment

by:mberumen
ID: 2775786
Here's the function I use

<script>
function openAWindow( pageToLoad, winName, width, height, center)

{
/* Opens a new window on the users desktop.   Arguments:
    pageToLoad - The URL of a page to load in the browser window.
                 This can be a relative URL or fully qualified.
    winName -        Name of the new window.
    width -        The horizontal size of the new window.
    height -        The vertical size of the new window.
    center -     toggle centering on 4.0 browsers.
                  1=centered window 0=no centering
    Values in the "args" section below can all be toggled in the
    same fashion as the center toggle.  Just modify the appropriate
    value in the args section to be either 0 or 1.
    A call to this function might look like this:
 
   Created by Glenn Davis of Project Cool, Inc. for general use.  If
   you use this routine please leave all comments in place so that
   others may benefit as well.*/                                   
   
   xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;    }
    args = "width=" + width + ","     + "height=" + height + ","
    + "location=0,"     + "menubar=0,"    + "resizable=1,"    + "scrollbars=0,"
    + "status=0,"     + "titlebar=0,"    + "toolbar=0,"    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only
    window.open( pageToLoad,winName,args );
    }</script>


To call the page use this anchor tag

 <a href="javascript:openAWindow('newwindow.html','editvalues',310,120,1)">
(this would open a quarter size screen on a 640x480 screen
I need to look up the function that determines the size of the user's screen
then you can make it exactly one quarter of their screen size)

Hope this gets you started
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2776445
window.screen.availWidth
window.screen.availHeight

these work both with IE and Netscpae (for netscape only you can use window.innerWidth)

CJ
0
 
LVL 8

Accepted Solution

by:
xabi earned 200 total points
ID: 2776452
Here hoes the answer:

--- 8< -------- 8< ---------
<html>
<head>
<title>Example</title>
<script language="JavaScript">
<!--
function openWindow() {
    iWidth  = screen.width
    iHeight = screen.height
    msgWindow = window.open('newpahe.htm','newWin','width=' + iWidth/2 + ',height=' + iHeight/2 + ',screenX=' + iWidth/4 + ',screenY=' + iHeight/4 + ',top=' + iWidth/4 + ',left=' + iHeight/4);
}
//-->
</script>
</head>
<body>
 <form>
  <input type="button" onClick="openWindow()" value="Click Me">
 </form>
</body>
</html>
--------- 8< ------- 8< --------
xabi
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:xabi
ID: 2776471
Even better
---------------- 8< ---------- 8< -------------
<html>
<head>
<title>Example</title>
<script language="JavaScript">
<!--
function openWindow(sAddr, iDivX, iDivY) {
    iSwidth  = screen.width
    iSheight = screen.height
    iWwidth  = iSwidth  / iDivX
    iWheight = iSheight / iDivY
    iLeft   = (iSwidth  - iWwidth)  / 2
    iTop    = (iSheight - iWheight) / 2
    msgWindow = window.open(sAddr,'newWin','width=' + iWwidth + ',height=' + iWheight + ',screenX=' + iLeft + ',screenY=' + iTop + ',top=' + iTop + ',left=' + iLeft);
}
//-->
</script>
</head>
<body>
 <form>
  <input type="button" onClick="openWindow('newpahe.htm',3,3)" value="Click Me">
 </form>
</body>
</html>
---------------- 8< ---------- 8< -------------

As you can see you onlye need to change the values when calling the function "openWindow"
1st  value is the URL
2nd  value is the Axis X proportion
3thd value is the Axis Y proportion

xabi
0
 
LVL 7

Expert Comment

by:ssdesign
ID: 2778022
Write this code between the </Title> and <head> tag

<script language="JavaScript">
<!-- hide from JavaScript-challenged browsers
function openWindow(url) {
popupWin = window.open(url,
'remote','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,dependent,width=400,height=200,left=50,top=50')}
// done hiding --></script>

In the body tag wgere you want to give the link for popup give this code

<a href="javascript:openWindow('xyz.htm');">popup</a>

As you can see you can set a lot of parameters as either true or false.

Hope this solves your problem in the easiest way.

0
 

Author Comment

by:scupps
ID: 2785102
Thank you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

733 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