PDA

View Full Version : making popups happen once per browser session


dannybugler
08-09-2002, 02:41 PM
Hi,

how can i make the following pop up window only pop up once per browser session?

thanks,

danny bugler

<script>
// set the popup window width and height

var windowW=337 // wide
var windowH=271 // high

// 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);

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

var urlPop = "resolution.htm"

// set the title of the page

var title = "Resolution"

// 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()}
}
}

function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
//-->
</script>

whackaxe
08-09-2002, 03:16 PM
session olny cookie

dannybugler
08-09-2002, 03:20 PM
sorry I'm a complete novice how would I go about that then??
:confused:

thanks,

danny bugler

requestcode
08-09-2002, 04:19 PM
Here is a link to a script from JavaScriptkit's Free Script Section that does just what you want using cookies.

http://www.wsabstract.com/script/cut65.shtml

You should be able to adapt it to your needs. Also if you check out the tutorials section I believe there is one on Cookies. Good Luck.

dannybugler
08-09-2002, 05:18 PM
why doesnt this work then? can't see what i've done wrong

thanks,

danny






<script>

/*
Fair well window launcher script
By JavaScript Kit (http://javascriptkit.com)
Over 200+ free scripts here!
*/

<!--


// set the popup window width and height

var windowW=337 // wide
var windowH=271 // high

// 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);

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

var urlPop = "fabrics.htm"

// set the title of the page

var title = "Fabrics"

// 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()}
}

function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function loadpopup(){
if (get_cookie('popped')==''){
MM_callJS('javascript:openFrameless()')
document.cookie="popped=yes"
}
}

</script>