Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

Archive for June, 2009

Check browser’s javascript enable or disable

Posted by Viral Sarvaiya on June 11, 2009

to check the java script is enable or disable, it is too easy use


<meta http-equiv=’refresh’ content=’0;url=’/>


here, if the java script is disable then it redirect to you site’s error page.if u want to write any thing instead of redirect then you can write any HTML tag with you message in .


Posted in Javascript | Tagged: | Leave a Comment »

Disable Right Click of Mouse with Javascript

Posted by Viral Sarvaiya on June 8, 2009

Make one javascript file named “dm.js” and put below code into it.
var omitformtags=[“input”, “textarea”, “select”]
function disableselect(e){
if (omitformtags.indexOf(
return false
function reEnable(){
return true
if (typeof document.onselectstart!=”undefined”)
document.onselectstart=new Function (“return false”)
var message = “”;
function clickIE() { if (document.all) { (message); return false; } }
function clickNS(e) {
(document.layers || (document.getElementById && !document.all)) {
if (e.which == 2 || e.which == 3) { (message); return false; }
if (document.layers)
{ document.captureEvents(Event.MOUSEDOWN); document.onmousedown = clickNS; }
else { document.onmouseup = clickNS; document.oncontextmenu = clickIE; }
document.oncontextmenu = new Function(“return false”)

Write the below line in your head section of your file.

<script src=”FrontJs/dm.js” language=”javascript” type=”text/javascript”></script>

Now Your Page is Right click protected for text and image even you can not select the text from your web page.

Posted in Javascript | Tagged: , , , | 1 Comment »

%d bloggers like this: