Jump to content

Can a function loadImage only occur once during initial page load?


Slonpenny

Recommended Posts

I am somewhat new to javascripting and am working on a page load for specific content. My interal client has requested an alert to occur when someone navigates to the home page. I added a popup alert to my webpage with the following javascripting:

 

function loadImage() { alert("This reference material contains confidential information and is not to be shared with team members who do not service private exchange business.");}

 

<body onload="loadImage()">

It's pretty simple, but my business partner has now asked that instead of it presenting on every load, they wish it to only present on the intial load of the webpage. I have searched w3schools, but can't seem to find any expressions that will handle this type of request.

Link to comment
Share on other sites

This is a Javascript question, not Java. I've moved the topic to the Javascript forum.

 

The solution to your problem is using cookies: http://www.w3schools.com/js/js_cookies.asp

 

Some people might suggest localStorage instead. If you think your target audience has versions of Internet Explorer newer than 7 then it's safe to use it.

Link to comment
Share on other sites

Personally, I loathe cookies. They're cumbersome, inefficient, limiting, and were mostly never intended to be used as they were. The cookie is technology from 20 years ago and has not aged well with the current-day demands of web applications. The only reason you would use cookies is like Ingolme said, for older IE versions.

 

However, that is not even a valid excuse anymore. I don't think it is worth wrapping your head around how to create, parse, and cleanup cookies just because a couple employees were too lazy to spend 2 minutes to update their IE. If they can't be bothered, I'd say make them see the pop up on every load until they do update. You can code a check for the browser to know what webstorage is and if it doesn't you can include in the popup that updating your browser will solve the constant popups.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...