...

View Full Version : Autoclose upon leave



twilight
07-04-2002, 11:08 PM
hi,
i found this preety powerful script:

<script>

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

// set the popup window width and height

var windowW=250 // wide
var windowH=400 // high

// set the screen position where the popup should appear

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

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

var urlPop = "framless2.htm"

// set the title of the page

var title = "Page Title"

// 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 = "width="+windowW+",height="+windowH;
var beIE = document.all?true:false

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

</script>


what i'm interested in is the autoclose-upon-leave part of this code. i modyfied this a bit and got something like this:

var lg = null;
var zamknij = true
function go(){
lg=window.open("page.htm")
lg.focus()
if (zamknij){
window.onunload = function(){lg.close()}
}
}

but this code is odd - sometimes it works, sometimes it doesn't (on the page that i rewrote it on everthing was just fine, but on the page that i actualy wanted to use this i get 'awaiting an object' message and nothing happens) and so i was wandering if i got this good. maybe there is another way of writing the same (one that woulg work for me)

my regards
mike



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum