Guest jester376 Posted April 22, 2011 Report Posted April 22, 2011 I need to know to limit this javascipt code to only happening one time even if the webpage is refreshed or downloaded several times. The code is: <OBJECT id=wolfi height=32 width=32 classid=CLSID:D45FD31B-5C6E-11D1-9EC1-00C04FD7081F> > </OBJECT> <script language=JavaScript type=text/javascript> function LoadLocalAgent(CharID, CharACS) { LoadReq = wolfi.Characters. Load(CharID, CharACS); return(true); } var MerlinID; var MerlinACS; wolfi.Connected = true; MerlinLoaded = LoadLocalAgent (MerlinID, MerlinACS); Merlin = wolfi.Characters.Character(MerlinID); Merlin.Show(); Merlin.Play("Surprised"); Merlin.Play("GetAttention"); Merlin.Play("GetAttention"); Merlin.Play("Blink"); Merlin.speak(" talk talk wizard"); Merlin.Play("Blink"); Merlin.Play("Confused"); Merlin.MoveTo (685,420); Merlin.Play('DoMAgic2'); Merlin.Play('DoMAgic2'); Merlin.Play("GetAttention"); Merlin.Play("Surprised"); Merlin.Play('GestureLeft'); Merlin.Play('GestureRight'); Merlin.speak("Questions?talk talk"); Merlin.MoveTo (210,420); Merlin.Play("GetAttention"); Merlin.Play('DoMAgic1');Merlin.Play('DoMAgic2'); Merlin.Play("Surprised"); Merlin.Play('GestureRight'); Merlin.Play("Blink"); Merlin.speak("Talk Talk"); Merlin.MoveTo (585,320); Merlin.Play("GetAttention"); Merlin.Play('DoMAgic1'); Merlin.Play('DoMAgic2'); Merlin.Play("Surprised"); Merlin.Play('GestureLeft'); Merlin.speak("Talk Talk"); Merlin.MoveTo (685,420); Merlin.Play("GetAttention"); Merlin.Play('DoMAgic1'); Merlin.Play('DoMAgic2'); Merlin.Play('GestureRight'); Merlin.speak("Talk Talk"); Merlin.MoveTo (500,600); Merlin.Play("GetAttention"); Merlin.Play("Surprised"); Merlin.Play('GestureLeft'); Merlin.speak(" Talk Talk") Merlin.Play('DoMAgic1');Merlin.Play('DoMAgic2'); Merlin.MoveTo (200,300); Merlin.Play("Blink"); Merlin.speak("Talk Talk"); Merlin.Hide(); func = func.onetime(); </SCRIPT> Advice would be appreciated. Quote
falkencreative Posted April 23, 2011 Report Posted April 23, 2011 I'm not really sure if this can be done with pure Javascript. One way that would probably work would be to use PHP. You could use PHP to set a cookie on the user's machine the first time they visit the site. If that cookie exists (indicating they have visited more than once), the site will know not to run the Javascript code you included above. Quote
BeeDev Posted April 27, 2011 Report Posted April 27, 2011 You could also use JavaScript to set and read cookies But yea, Ben's right, Cookies is the way to go if you can't use server-side language. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.