I was working on a WordPress project which i need to clear the PHP session when the browser or browser tab is closed. Although Javascript provides the window.onbeforeunload event but it will be triggered even whenever you leave the website. Finally i got a simple solution from Daniel Melo in StackOverflow. The following code required jQuery and i have included the Google one in the HTML.
This is another example of implementing simple Ajax GET request. Please refer to Ajax – Simple Ajax POST Request for a POST request. Actually, both of them are quite similar and it is good to try both to get more familiar with the generic Ajax requests.
There is no sleep()/wait() function in Javascript. The setTimeout() is not exactly a sleep()/wait() function as it behaves like creating another thread for the scheduled task.
I just realized that the <hr /> divider line is not longer working in wordpress.com. Luckily i find a very good post which has several pieces of HTML codes to add the divider in WordPress post.
This is the last iPhone application i wrote when i was working in HKU and it is the most complicated one among the 3 apps since it needs to handle different types of questions like drag n drop and multiple choice… etc
In PHP, we can use the header() function to redirect the URL.
In HTML, we can use the meta tag to redirect the URL.
For more information, visit PHP/HTML – Redirect URL in Seconds