How would I make an mp3 play on my html page but only the first time someone enters? So that if they came back to that same page a second time they wouldn't hear the sound a second time?
EDIT: I know how to play sounds and everything I just need to find out the 'first time only' part of it.
just so coincident i have a piece of codes that dealing with cookies. As suggested by all from the comments above, it may introduce some bad user experience upon first landing. But this is something help to kick off
function setCookie(days) {
var date = new Date();
date.setTime(+date + (days * 86400000)); //how many days to expired
document.cookie = 'urCookieName=true; expires=' + date.toGMTString() + '; path=/';
}
function hasCookie() {
return (document.cookie.indexOf('urCookieName') !== -1);
}
if (!hasCookie()) {
//play the sound
...
//set the cookie
setCookie(365);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.