I'd like to run this javascript function only for one time (first page load). Is it possible? Thank you
<div id="pag">
<script type="text/javascript">
var framekiller = true;
window.onbeforeunload = function () {
if (framekiller) {
return "Click on stay on this 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 this page";
}
};
</script>
<iframe scr="http://www.example.com/page-with-javascript-framebuster.html"></iframe>
And put somewhere else, another javascript snipper, who turn this variable into false, and do other things.. eg opens a new link? To turn it back to false, use:
window.framekiller = false;
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.