browser - Run javascript function only for one time (first page load) -


i'd run javascript function 1 time (first page load). possible? thank you

<div id="pag"> <script type="text/javascript">  var framekiller = true;  window.onbeforeunload = function () { if (framekiller) {     return "click on stay on page"; } };  </script>  <iframe scr="http://www.example.com/page-with-javascript-framebuster.html"></iframe> </div> 

you should use global variables in javascript.

<script type="text/javascript">  window.framekiller = true;  window.onbeforeunload = function () { if (window.framekiller) {     return "click on stay on page"; } };  </script>  <iframe scr="http://www.example.com/page-with-javascript-framebuster.html"></iframe> 

and put somewhere else, javascript snipper, turn variable false, , other things.. eg opens new link? turn false, use:

window.framekiller = false; 

Comments

Popular posts from this blog

javascript - JS causing window size to be bigger than necessary - Dropdown bug -

How to mention the localhost in android -

php - Calling a template part from a post -