Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Popup Page with exit option

Status
Not open for further replies.

SoyDelicious

Technical User
Jul 23, 2002
46
US
What I'm trying to do is create a popup page that will display a picture. Although when the user clicks a link in the parent window I want the popup to close. Have any ideas. Or know of a good tutorial that could point me in the right direction? Thanks in advance.
 
I ran accross this snippet while searching for some other stuff... maybe it will help you out..


==============================================================
Script: Amazing Frameless Popup Window - Version I

Functions: In IE4 and later, this script launches a popup
window without the Windows frame or titlebar
(that is, a "containerless" window). In other
browsers, it launches a standard popup window.
Position, width, and height are settable.
Automatic closing of the window on leaving the
page may also be optionally set.

Browsers: IE4 and later
Degrades fully functionally in other browsers

Author: etLux
==============================================================

STEP 1.
Inserting the <script> in your page

Put the following <script> </script> in the head
section of your launching page.

Set the variables as indicated in the script.

<script>

// Amazing Frameless Popup Window - Version I
// (C) 2000 // Free for all users, but leave in this header

// set the popup window width and height

var windowW=214 // wide
var windowH=398 // high

// set the screen position where the popup should appear

var windowX = 260 // from left
var windowY = 100 // from top

// set the url of the page to show in the popup

var urlPop = &quot;yourpage.html&quot;

// set the title of the page

var title = &quot;This Is A Frameless Popup Window&quot;

// set this to true if the popup should close
// upon leaving the launching page; else, false

var autoclose = true

// ============================
// do not edit below this line
// ============================

s = &quot;width=&quot;+windowW+&quot;,height=&quot;+windowH;
var beIE = document.all?true:false

function openFrameless(){
if (beIE){
NFW = window.open(&quot;&quot;,&quot;popFrameless&quot;,&quot;fullscreen,&quot;+s)
NFW.blur()
window.focus()
NFW.resizeTo(windowW,windowH)
NFW.moveTo(windowX,windowY)
var frameString=&quot;&quot;+
&quot;<html>&quot;+
&quot;<head>&quot;+
&quot;<title>&quot;+title+&quot;</title>&quot;+
&quot;</head>&quot;+
&quot;<frameset rows='*,0' framespacing=0 border=0 frameborder=0>&quot;+
&quot;<frame name='top' src='&quot;+urlPop+&quot;' scrolling=auto>&quot;+
&quot;<frame name='bottom' src='about:blank' scrolling='no'>&quot;+
&quot;</frameset>&quot;+
&quot;</html>&quot;
NFW.document.open();
NFW.document.write(frameString)
NFW.document.close()
} else {
NFW=window.open(urlPop,&quot;popFrameless&quot;,&quot;scrollbars,&quot;+s)
NFW.blur()
window.focus()
NFW.resizeTo(windowW,windowH)
NFW.moveTo(windowX,windowY)
}
NFW.focus()
if (autoclose){
window.onunload = function(){NFW.close()}
}
}

</script>

==============================================================

STEP 2.
Triggering the popup window

Call the openFrameless function from a link, like this:

<a href=&quot;javascript:eek:penFrameless()&quot;>click here</a>

==============================================================

STEP 3.
Conditioning the page that goes in the popup window

Add the following call to the <body> tag of the page that
will open in the popup *if* your popup does not come to the
front after it loads. This is occasionally needed in early
versions of IE4, and with certain types of page content that
manipulate focus. If in doubt, put it in -- it can't hurt.

<body onload=&quot;top.window.focus()&quot;>

==============================================================

ADDENDUM 2/22/2001
Making the Frameless Popup Center on the Screen Automatically

We've had numerous requests for this, and a minor modification
of the script can do it. Here's how...

Comment out the two lines as shown, and add the two shown below
them.

// set the screen position where the popup should appear

//var windowX = 260 // from left
//var windowY = 100 // from top
var windowX = (screen.width/2)-(windowW/2);
var windowY = (screen.height/2)-(windowH/2);

==============================================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top