Tuesday, May 6, 2008

How to add Alert Box with Confirmation Button

This Alert Box is very useful if your site has a explicit content or not for the general public and want your readers to choose if they still want to continue entering your site or be redirected to a safe place.


► Under the Layout tab select Page Elements and add a HTML/JavaScript page element
► Copy and paste the code below
► Change the line "Enter your message here" with the your own set of message just like in my example output I've change it to "This site contains explicit contents. Are you sure you want to continue?".
► Change "YOUR BLOG URL" with the URL of your blog
► Change "SAFE LOCATION URL" with the URL of the site where you want your visitors to redirected after clicking the cancel button

ex. my url is http://blogging-for-starters.blogspot.com and the the safe place that I use is http://google.com. when a user clicks on the OK button he will be able to go and read my blog contents. when a user chooses to cancel he will be redirected to a safe place that I specify which is Google.



<script type="text/javascript">
confirm('Enter your message here 1');
if (confirm('
Enter your message here 2')) {
window.location = "YOUR BLOG URL";
}
else {
window.location = "SAFE LOCATION URL";
}
</script>

0 comments: