Pop layer kun én gang
Jeg har fundet et script som kan poppe et layer. Det skal bruges til et spørgeskema, og jeg er således kun interesseret i at det bliver vist én gang til hver bruger.Scriptet er fra plx og kan hentes her: http://plxwebdev.com/script/id-15
Scriptet i aktion:
http://www.uglegaarden.dk/mikkel/popup/
Koden fra scriptet nederest.
Hva jeg kan læse på plx's side, så bør man kunne sætte en cookie som sikrer at brugeren kun ser det én gang. Er der nogen som er lidt hjemme i javascript som kan se hva der skal til for at layer kun popper én gang??
Og her koden:
<!--
///////////////////////////////////////////////////////////////////////////
// This script was designed by plx Web Studio //
// //
// For more info: http://plxwebdev.com //
// Contact Email: admin@plxwebdev.com //
/////////////////////////////////////////////////////////////////////////
// languages - comment any language you don't support and specify urls for these you support
var langletters = new Array();
var languages = new Array();
var site_url = '';
var index_prefix = '';
langletters[0] = 'default'; languages[0] = site_url + index_prefix + 'english.html'; //default language
langletters[1] = 'en'; languages[1] = site_url + index_prefix + 'english.html';
langletters[2] = 'nl'; languages[2] = site_url + index_prefix + 'dutch.html';
langletters[3] = 'fr'; languages[3] = site_url + index_prefix + 'french.html';
langletters[4] = 'de'; languages[4] = site_url + index_prefix + 'german.html';
langletters[5] = 'ja'; languages[5] = site_url + index_prefix + 'japanese.html';
langletters[6] = 'it'; languages[6] = site_url + index_prefix + 'italian.html';
langletters[7] = 'pt'; languages[7] = site_url + index_prefix + 'portuguese.html';
langletters[8] = 'es'; languages[8] = site_url + index_prefix + 'spanish.html';
langletters[9] = 'sv'; languages[9] = site_url + index_prefix + 'swedish.html';
langletters[10] = 'zh'; languages[10] = site_url + index_prefix + 'chinese.html';
var uselayer = 1; // 0=no; 1=yes
var usefarewellpop = 0; // 0=no; 1=yes
var usewelcomepop = 1; // 0=no; 1=yes
var usepopunder = 0; // 0=no; 1=yes
var popunder_one_time = 0; // Load new PopUnder only once per browser session? (0=no, 1=yes);
var popunder_timed = 2; // timed popunder in seconds; use 0 to pop on load
var popunder_uselanguage = 1; //0=no; 1=yes; 1 - redirects the browser depending on the language and the languages specified - see 'languages' above
// Specify the width and height of new popunder window (in pixels).
var popunder_width = '700';
var popunder_height = '450';
// set any of these appearance settings as you wish
var popunder_props = 'scrollbars=yes,resizable=yes,toolbar=yes,' +
'menubar=yes,status=yes,location=yes,left=85,top=20,height=' +
popunder_height + ',width=' + popunder_width;
var usepopup = 1; // 0=no; 1=yes
var popup_one_time = 0; // Load new PopUnder only once per browser session? (0=no, 1=yes);
var popup_timed = 2; // timed popunder in seconds; use 0 to pop on load
var popup_uselanguage = 1; //0=no; 1=yes; 1 - redirects the browser depending on the language and the languages specified - see 'languages' above
// Specify the width and height of new popup window (in pixels).
var popup_width = '700';
var popup_height = '450';
// set any of these appearance settings as you wish
var popup_props = 'scrollbars=yes,resizable=yes,toolbar=yes,' +
'menubar=yes,status=yes,location=yes,left=85,top=20,height=' +
popup_height + ',width=' + popup_width;
// general functions
isIE = document.all;
isNN =! document.all && document.getElementById;
isN4 = document.layers;
isHot = false;
var desitnayionurl;
function GetLanguage(uselang) {
if (!uselang) return languages[i];
if (navigator.appName == 'Netscape') var language = navigator.language;
else var language = navigator.browserLanguage;
var desitnayionurl = '';
for (var i = 1; i <= langletters.length; i++) {
letter = langletters[i];
if (language.indexOf(letter) > -1) {
desitnayionurl = languages[i];
break;
}
}
if (!desitnayionurl) desitnayionurl = languages[0];
return desitnayionurl;
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if the cookie exists
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
// making popunder
desitnayionurl = GetLanguage(popunder_uselanguage)
function popunder_loadornot(){
if (get_cookie('popunder')==''){
load_pop_under()
document.cookie="popunder=yes"
}
}
function load_pop_under(){
if (!usepopunder) return;
win2 = window.open(desitnayionurl, "popunder", popunder_props);
win2.blur();
window.focus();
}
function GoLoadPopUnder() {
if (popunder_one_time==0) load_pop_under();
else popunder_loadornot();
if (popunder_timed) clearTimeout(popundertimer);
}
// making popup
function popup_loadornot(){
if (get_cookie('popup')==''){
load_pop_up()
document.cookie="popup=yes"
}
}
function load_pop_up(){
if (!usepopup) return;
window.open(desitnayionurl, "popup", popup_props);
}
function GoLoadPopUp() {
if (popup_one_time==0) load_pop_up();
else popup_loadornot();
if (popup_timed) clearTimeout(popuptimer);
}
function GeneralLoader(wentunload) {
if (wentunload && !usefarewellpop) return;
if (!wentunload && !usewelcomepop) return;
if (wentunload && usefarewellpop) {
GoLoadPopUnder();
GoLoadPopUp();
return;
}
if (popunder_timed) popundertimer = setTimeout("GoLoadPopUnder()", 1000*popunder_timed);
else GoLoadPopUnder();
if (popup_timed) popuptimer = setTimeout("GoLoadPopUp()", 1000*popup_timed);
else GoLoadPopUp();
if (uselayer) showMe();
else hideMe();
}
function ddInit(e){
topDog = isIE?"BODY":"HTML";
whichDog = isIE?document.all.theLayer : document.getElementById("theLayer");
hotDog=isIE ? event.srcElement : e.target;
while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
}
if (hotDog.id=="titleBar"){
offsetx=isIE ? event.clientX : e.clientX;
offsety=isIE ? event.clientY : e.clientY;
nowX=parseInt(whichDog.style.left);
nowY=parseInt(whichDog.style.top);
ddEnabled=true;
document.onmousemove=dd;
}
}
function dd(e){
if (!ddEnabled) return;
whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
return false;
}
function ddN4(whatDog){
if (!isN4) return;
N4=eval(whatDog);
N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
N4.onmousedown = function(e) {
N4.captureEvents(Event.MOUSEMOVE);
N4x=e.x;
N4y=e.y;
}
N4.onmousemove = function(e){
if (isHot){
N4.moveBy(e.x-N4x,e.y-N4y);
return false;
}
}
N4.onmouseup=function(){
N4.releaseEvents(Event.MOUSEMOVE);
}
}
function hideMe(){
whichDog = isIE?document.all.theLayer : document.getElementById("theLayer");
if (isIE||isNN) whichDog.style.visibility="hidden";
else if (isN4) document.theLayer.visibility="hide";
}
function showMe(){
whichDog = isIE?document.all.theLayer : document.getElementById("theLayer");
if (isIE||isNN) whichDog.style.visibility="visible";
else if (isN4) document.theLayer.visibility="show";
}
document.onmousedown = ddInit;
document.onmouseup = Function("ddEnabled=false");
-->