JavaScript Confirm Box

2 Comments

Many times, in life, one needs to confirm things. For example, you might be writing a UI for a nuclear submarine and you need to add a confirm box whether the link should be followed (which might as a result launch a nuke or delete a record) or not. You can do it the hard way by writing PHP/ASP code but I like to do it the easy way, by using JavaScript.

A really simple approach is:

 html |  copy code |? 
1
<a href="nuke.php?launch=yes" onclick="return confirm('Are you sure you want to destroy humanity?')">Delete</a>

When the user clicks on it, this will produce the a pop up box, displaying that message and two buttons. If the user click yes, the link is followed otherwise nothing happens, and we live again ;)

Block access to .htaccess

2 Comments

Before I answer the ‘how’, let me answer the ‘why’.

.htaccess, now a days, plays a major role. It lets you re-write URLs, redirect traffic, and if you are really good with it, point people to different scripts on your website. It is also an excellent way to cloak your web space structure.

The problem occurs if someone is able to have a look at your .htaccess file and see how things are processed at the ‘back stage’. Or the reason could be that you have written a state-of-an-art .htaccess file and want those 16 year olds to stay away from it.

Just place this at the top of your .htaccess file and you can sleep peacefully, once again ;)

 apache |  copy code |? 
1
<files .htaccess>
2
order allow,deny
3
deny from all
4
</files>