JavaScript - Distinguish Between Pagereload/pagerefresh And Pageclose
I have a requirement where if the page is refreshed or reloaded then one function will be called and if the page is closed some other function will be called. but i can not distinguish between these two events. I have used onbeforeunload and unload event. Please help.
Similar Tutorialsi want to have the capability similar as that of vbulletin so that if user is writing reply using 'quick reply' & want to move to full editor page the contents be preserved. @phpbb3 (I am successful needs optimisation) 1] the textarea id is similar both in quick & full reply editors 2] When replying a special string is there in url my code: Code: var field = document.getElementById("text_editor_textarea"); if (sessionStorage.getItem("autosave") && document.URL.indexOf("mode=reply") > 0) { field.value = sessionStorage.getItem("autosave"); } if (field) { setInterval(function() { sessionStorage.setItem("autosave", field.value); }, 1e3); } Now everone knows this time interval function is heavy for browsers...so I want to start ts only when field.value.length > 0 but I am unable to do so. Any suggestions. Simply this willnt work Code: if (field && field.value.length > 0) { Consider the following piece of code: PHP Code: <form method='post' name='myform'> <input type='submit' name='sub' value='submit 1' /> <input type='submit' name='sub' value='submit 2' /> <a href='javascript:document.myform.submit();'>submit 3</a> </form> <?php echo "You clicked ".$_POST["sub"]; ?> So if you click "submit 1", the output will be You clicked submit 1. And if you click "submit 2", the output will be You clicked submit 2. That's obvious. But ... what do I need to do to pass the key/value pair "sub" = "submit 3" to the server via POST when I click on the hyperlink showing "submit 3" - so that the output is You clicked submit 3 (i.e. so that $_POST contains "submit 3" referenced to index "sub"). I've tried <a href='javascript: a = {"x" : 1}; document.myform.submit(a);'>submit 3</a>, but that doesn't cause a to be passed via POST. |