I want to run a javascript one time.
I tried using a script from Dynamic Drive, but it seems to not work with scripts.
I want it to run the first time the user visits the page, but then doesn’t pop up again.
Any help?
My script is
<script src="http://www.google.com/jsapi"></script><script>google.load("jquery", "1");</script>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script type="text/javascript">
Username="___", <!-- Facebook Username Without http://facebook.com/ -->
Title="Join Our Facebook!", <!-- Title -->
Skin="01", <!-- 01 Through 04 -->
Time="15", <!-- Countdown In Seconds -->
Wait="0", <!-- Wait For Popup -->
Lang="en"
</script>
<script type="text/javascript" src="likeboxfbfanpro.js"></script>
<script type="text/javascript">$(document).ready(function(){$().popupbox({ closeable: false });});</script>
You can do two things:
Set a cookie after the first time you show the message and test for the existence of the cookie on each page load. Show the message if the cookie does not exist or skip it if it does.
Set a server side session value (session only), or a database record (spans sessions if you can somehow identify the returning visitor (i.e. IP)) to control the HTML after the first page is served to the client. Only send the message html if there is no session/database value yet
If you want to set cookies. Here’s a small script that does the cookie handling:
Now in your code you can use this as follows: