Closed Thread Icon

Topic awaiting preservation: onload event (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8490" title="Pages that link to Topic awaiting preservation: onload event (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: onload event <span class="small">(Page 1 of 1)</span>\

 
lawrie
Obsessive-Compulsive (I) Inmate

From:
Insane since: Jan 2003

posted posted 01-27-2003 11:58

Hi,
I want to run a small flash animation on one page and a 'layeranimagic' function on another.....but only once!
I have found a javascript which sets a cookie which allows a similar action with a popup window but I know too little to even try to modify it.
any help or direction to a simple tutorial welcome
cheers

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 01-27-2003 13:16

lawrie: Could you drop in the code you have found so we show you exactly what needs doing?

___________________
Emps

FAQs: Emperor

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-27-2003 13:16

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

kuckus
Bipolar (III) Inmate

From: Berlin (almost)
Insane since: Dec 2001

posted posted 01-27-2003 14:13

If I understood you correctly all you need to do is having the onload event point to a function like this:

function checkCookie() {
if (document.cookie) {
document.write("You've visited this site before - welcome back!");
}
else {
document.write("This is your first visit to this site - welcome!");
// Execute the function:
layeranimagic();
// Set the cookie:
document.cookie = "visited=true";
}
}

Instead of executing the "layeranimagic" function in the else block you could also toggle the visibility of a flash movie or redirect the visitor to another page.

Hope that helps a bit.

kuckus

[This message has been edited by kuckus (edited 01-27-2003).]

lawrie
Obsessive-Compulsive (I) Inmate

From:
Insane since: Jan 2003

posted posted 01-27-2003 16:02

Hi,
thanks for the help & sorry bout not being specific.
I have seen cookie scripts which only allow an event to happen on a visitors first visit.
One of the things I want to do is get an action like the one below to occur only once but I do not know enough to modify a script. Animagic is a flexible way to move layers. I have included the script with the onload event.
<script language="JavaScript" type="text/JavaScript">
<!--

function P7AniMagic(el, x, y, a, b, c, s) { //v2.8 PVII
var g,elo=el,f="",m=false,d="";x=parseInt(x);y=parseInt(y);
var t = 'g.p7Magic = setTimeout("P7AniMagic(\''+elo+'\',';
if ((g=MM_findObj(el))!=null) {d=(document.layers)?g:g.style;}else{return;}
if (parseInt(s)>0) {eval(t+x+','+y+','+a+','+b+','+c+',0)",' + s+')');return;}
var xx=(parseInt(d.left))?parseInt(d.left):0;
var yy=(parseInt(d.top))?parseInt(d.top):0;
if(parseInt(c)==1) {x+=xx;y+=yy;m=true;c=0;}
else if (c==2) {m=false;clearTimeout(g.p7Magic);}
else {var i=parseInt(a);
if (eval(g.moved)){clearTimeout(g.p7Magic);}
if (xx<x){xx+=i;m=true;if(xx>x){xx=x;}}
if (xx>x){xx-=i;m=true;if(xx<x){xx=x;}}
if (yy<y){yy+=i;m=true;if(yy>y){yy=y;}}
if (yy>y){yy-=i;m=true;if(yy<y){yy=y;}}}
if (m){if((parseInt(navigator.appVersion)>4 &#0124; &#0124; navigator.userAgent.indexOf("MSIE")>-1)&& navigator.userAgent.indexOf("Opera")==-1){
xx+="px";yy+="px";}
d.left=xx;d.top=yy;g.moved=true;eval(t+x+','+y+','+a+','+b+','+c+',0)",'+b+')');
}else {g.moved=false;}
}
//-->
</script>
</head>

<body onLoad="P7AniMagic('content',333,123,5,30,0,0)">

thanks for the help

kuckus
Bipolar (III) Inmate

From: Berlin (almost)
Insane since: Dec 2001

posted posted 01-27-2003 20:41

OK what you need to do now is replacing the "layeranimagic()" call in my function with the name of your function and the arguments it needs (that's what you have in the onload now), then paste the checkCookie() funtion into your JavaScript section and finally change the body's onload event to trigger the checkCookie() function instead of the other one.

lawrie
Obsessive-Compulsive (I) Inmate

From:
Insane since: Jan 2003

posted posted 01-28-2003 11:33

thanks, working on it now

lawrie
Obsessive-Compulsive (I) Inmate

From:
Insane since: Jan 2003

posted posted 01-28-2003 12:14

doh!
can't get it to work.
posted a test page at: http://www.newburghpriory.co.uk/cookie.htm
cheers

« BackwardsOnwards »

Show Forum Drop Down Menu