![]() |
Help? Show JavaScript Once Per Day Only?
Help. How do I show the below JavaScript code to each unique visitor only once per day or any amount of days I want to set?
PHP Code:
|
You need to set a cookie. Many examples have been posted in this forum - here is one of them. You set the expiry date to the desired number of days ahead (here 365 days - change yours to 1 or whatever).
Code:
<html>Quizmaster: What is the only prime number between 75 and 80? Contestant: 99 |
Please help. :o
I don't know how to set a cookie with my particular code. Can someone help me & provide it in my code and paste it here? I have no idea what to do. :( |
What is wrong with the code I gave you in Post #2? And why are you shouting?
Presumably you would not attempt to service or repair a machine or appliance without any experience or understanding of how it worked. |
Quote:
I've tried codes like yours I can't figure it out & need help getting it working with my code specifically.. :( |
Is the <div> you want to show/hide
<div id="slideInShade" style="position:absolute;z-index:99;visibility:hidden;"></div> (that is the rectangle with a "close" button)? Make up your mind. Do you want it to display once per browser session or once per day? |
It is not difficult to do what you want.
a) delete this line f_slideIn(); which you will find right in front of </script> b) place the two scripts which I gave you in Post#2 in the <head> and <body> respectively of your page. Right after the <head> and the <body> tags. c) change the script in the body as follows:- Code:
<body> |
Help; this doesn't work. The code above doesn't work with my code. Here is what I did to combine my code with the above code & it does NOT work :(
PHP Code:
I'd like to to show this to each user on each browser session and/or every day. Please help. |
Quote:
Help |
Sorry, you have not done what I suggested, and your boorish ill-manners means that I am not interested in helping you further. I don't like it when people shout at me. :mad:
In any case you are obviously too inexperienced and lacking in knowledge of JavaScript to make use of any advice given. |
Hi Philip M, wanted to express my gratitude for posting this answer and greatly helped me to achieve what i was looking for even if this a 9 months old thread. i am an inexperienced coder my self (not even a coder) i am a web designer but polite and have always learned to give credit to people like you , sharing knowledge is what is driving all of us to go forward..
i got here via google and this was exactly what i was looking for just i want this to modify it to accept lesser period than a day eg 1 hour. you can see the use of it on this website www.myfxcentral.gr it uses your code to show the jpopup in joomla only once per user per day, but i want this to set it a lesser period. thank you. john btw if you need anything to see how i used your code or anything i will provide asap thanks |
Quote:
Code for cookies: Code:
/***(1) var name = 'Joe Smith'; (2) writeCookie('username', name, 30); (a cookie named 'username' with a value of 'Joe Smith' is saved on the client's machine and it stays there for 30 days. (3) .... sometime later..... (4) var name = readCookie('username'); (5) alert(name); (displays 'Joe Smith' retrieved from the client's machine). Code for local storage: Code:
/***Hope this helps you....... -- Roger |
To set a cookie which will expire in one hour:-
Code:
<script type = "text/javascript"> |
If you have a server side language you can use I would recommend doing this server side as any cookies and/or javascript solutions will not work if they are disabled in the visitors' browser.
|
Quote:
Disabled cookies is a more plausable situation, but in that case the cookies are disabled both from client-side and from server-side. |
| All times are GMT +1. The time now is 09:41 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.