Sometimes you don't want people who visit your blog can not right click or select any thing. Follow the step you can do this. Just copy and paste these code below. Where you can paste these code?
- On a new Widget (with Blogspot, Wordpress,...)
- On a new post that support javascript (Blogspot) - With this, code only work with single post.
- On a template (between <body></body> tag)
1/ Prevent Right Click And Select: Just copy and paste this script: Exp: http://test.vtechtip.com/2009/11/prevent-right-click-and-select.html
<script language='javascript'>
document.onselectstart=new Function('return false');
function ds(e){return false;}
function ra(){return true;}
document.onmousedown=ds;
document.onclick=ra;
document.oncontextmenu = function (){ return false};
</script>
<script language='JavaScript'>
if (top.location != self.location)
{top.location = self.location}
</script>
2/ Prevent Select Only: Ex: http://test.vtechtip.com/2009/11/prevent-right-click-only.html
<script language='javascript'>
document.onselectstart=new Function('return false');
function ds(e){return false;}
function ra(){return true;}
document.onmousedown=ds;
document.onclick=ra;
</script>
<script language='JavaScript'>
if (top.location != self.location)
{top.location = self.location}
</script>
document.onselectstart=new Function('return false');
function ds(e){return false;}
function ra(){return true;}
document.onmousedown=ds;
document.onclick=ra;
</script>
<script language='JavaScript'>
if (top.location != self.location)
{top.location = self.location}
</script>
3/ Prevent Right Click Only: Ex: http://test.vtechtip.com/2009/11/prevent-right-click-only_01.html
<script language='javascript'>
document.onselectstart=new Function('return false');
function ds(e){return false;}
function ra(){return true;}
document.oncontextmenu = function (){ return false};
</script>
<script language='JavaScript'>
if (top.location != self.location)
{top.location = self.location}
</script>
document.onselectstart=new Function('return false');
function ds(e){return false;}
function ra(){return true;}
document.oncontextmenu = function (){ return false};
</script>
<script language='JavaScript'>
if (top.location != self.location)
{top.location = self.location}
</script>
No comments:
Post a Comment