Solved

Code for popping up quarter-page brower windows

Posted on 2000-05-03
6
172 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 8

Expert Comment

by:xabi
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

744 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

15 Experts available now in Live!

Get 1:1 Help Now