If you only want to display the message once per visitor, you'll have to use some client side storage such as cookies.
Here's a working example:
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Message Cookie Demo</title>
<style>
#message{
background-color: yellow;
padding: 5px;
display: none;
}
</style>
</head>
<body>
<h1>Hello, there!</h1>
<h2>This is some content</h2>
<p id="message">
This message will vanish after 5 seconds. It will only display once"
</p>
<script src="https://rawgit.com/js-cookie/js-cookie/master/src/js.cookie.js"></script>
<script>
var hasSeenMessage = Cookies.get("hasSeenMessage")
if (!hasSeenMessage){
var message = document.getElementById("message");
message.style.display = "block";
Cookies.set('hasSeenMessage', true, { expires: 1, path: '/' });
setTimeout(function(){
message.style.display = "none"
}, 5000);
}
</script>
</body>
</html>
This uses the following cookie library. The cookie will expire after one day and is valid across the entire site. You can easily tweak this to suit your purposes.
When you try this demo, be sure to run it on a server. It won't work locally in some browsers.