0

Any one knows how to remove content editor after first load. I want to load the page with content editor for the first time but after page refresh the content editor should be removed from the page. Please suggest the help. Thanks in advance

2
  • 2
    What kind of requirement is this? – Kaushal Khamar Mar 28 '16 at 7:25
  • I have script inside the content editor and i want to run this script only for first time. – Mrunal Shidurkar Mar 28 '16 at 7:27
2

You can use locastorage or cookies for your requirement, localstorage can be used to store custom string values on custom key values.You can have the below code in the page load to determine whether the page has been loaded already or not.

if(localStorage.getItem('first') === null){
  toBeExecutedOnFirstLoad();
  localStorage.setItem('first','nope!');
}

OR

if (localStorage['...my key here...'] === '...my expected value here...') {
    // The page has been visited before
} else {
    // The page has not been visited before
    // OR
    // The user or script has cleared the localStorage value
}
localStorage['...my key here...'] = '...my expected value here...';

NOTE:

  1. If the user deletes his cookies and or other site plugin data then it will refresh.

  2. If you want to show the page again for next session, replace localStorage with sessionStorage

  3. For more information on localstorage, click here

1
  • And for a more permanent solution, one could mix the localStorage with a user profile property. – Anders Aune Apr 2 '16 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.