PDA

View Full Version : No Right Click(The Special Way)



amosngweien
12-03-2009, 10:31 AM
This Is Easy

Go To http://www.dynamicdrive.com/dynamicindex9/noright3.htm And Get The Code
Should Be Something Like This :
Add Into Head Tag


<script language=JavaScript>
<!--

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(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")
// -->

</script>

Next, Add


<div id="ie5menu" class="b1" onMouseover="highlightie5(event)" onMouseout="lowlightie5(event)" onClick="jumptoie5(event)" display:none>
Hello! No Ripping !
</div>
<script language="JavaScript1.2">

//set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar
var display_url=0

var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
if (ie5||ns6)
var menuobj=document.getElementById("ie5menu")

function showmenuie5(e){
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX
var bottomedge=ie5? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? document.body.scrollLeft+event.clientX-menuobj.offsetWidth : window.pageXOffset+e.clientX-menuobj.offsetWidth
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX

//same concept with the vertical position
if (bottomedge<menuobj.offsetHeight)
menuobj.style.top=ie5? document.body.scrollTop+event.clientY-menuobj.offsetHeight : window.pageYOffset+e.clientY-menuobj.offsetHeight
else
menuobj.style.top=ie5? document.body.scrollTop+event.clientY : window.pageYOffset+e.clientY

menuobj.style.visibility="visible"
return false
}

function hidemenuie5(e){
menuobj.style.visibility="hidden"
}

function highlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node
firingobj.style.backgroundColor="highlight"
firingobj.style.color="black"
if (display_url==1)
window.status=event.srcElement.url
}
}

function lowlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node
firingobj.style.backgroundColor=""
firingobj.style.color="826A92"
window.status=''
}
}

function jumptoie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode
if (firingobj.getAttribute("target"))
window.open(firingobj.getAttribute("url"),firingobj.getAttribute("target"))
else
window.location=firingobj.getAttribute("url")
}
}

if (ie5||ns6){
menuobj.style.display=''
document.oncontextmenu=showmenuie5
document.onclick=hidemenuie5
}

</script>
<style type="text/css">
.b1{
position:absolute;
width:130px;
background-color:white;
border:1px dotted #FFFFFF;
line-height:12px;
color: #AAAAAA;
font-size:8pt;
font-family:trebuchet ms;
text-align:left;
padding-bottom:5px;
padding-top:5px;
padding-left:5px;
padding-right:2px;
z-index:50;
visibility:hidden;
}
</style>

Add Both To The Head Tag
The Completed Code:


<script language=JavaScript>
<!--

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(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")
// -->

</script>
<div id="ie5menu" class="b1" onMouseover="highlightie5(event)" onMouseout="lowlightie5(event)" onClick="jumptoie5(event)" display:none>
Hello! No Ripping !
</div>
<script language="JavaScript1.2">

//set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar
var display_url=0

var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
if (ie5||ns6)
var menuobj=document.getElementById("ie5menu")

function showmenuie5(e){
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX
var bottomedge=ie5? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? document.body.scrollLeft+event.clientX-menuobj.offsetWidth : window.pageXOffset+e.clientX-menuobj.offsetWidth
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX

//same concept with the vertical position
if (bottomedge<menuobj.offsetHeight)
menuobj.style.top=ie5? document.body.scrollTop+event.clientY-menuobj.offsetHeight : window.pageYOffset+e.clientY-menuobj.offsetHeight
else
menuobj.style.top=ie5? document.body.scrollTop+event.clientY : window.pageYOffset+e.clientY

menuobj.style.visibility="visible"
return false
}

function hidemenuie5(e){
menuobj.style.visibility="hidden"
}

function highlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node
firingobj.style.backgroundColor="highlight"
firingobj.style.color="black"
if (display_url==1)
window.status=event.srcElement.url
}
}

function lowlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node
firingobj.style.backgroundColor=""
firingobj.style.color="826A92"
window.status=''
}
}

function jumptoie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode
if (firingobj.getAttribute("target"))
window.open(firingobj.getAttribute("url"),firingobj.getAttribute("target"))
else
window.location=firingobj.getAttribute("url")
}
}

if (ie5||ns6){
menuobj.style.display=''
document.oncontextmenu=showmenuie5
document.onclick=hidemenuie5
}

</script>
<style type="text/css">
.b1{
position:absolute;
width:130px;
background-color:white;
border:1px dotted #FFFFFF;
line-height:12px;
color: #AAAAAA;
font-size:8pt;
font-family:trebuchet ms;
text-align:left;
padding-bottom:5px;
padding-top:5px;
padding-left:5px;
padding-right:2px;
z-index:50;
visibility:hidden;
}
</style>

Demo: My Site (http://www.amos-ng.co.cc)

traq
12-03-2009, 03:17 PM
that's easy to break. Just turn javascript off. read more... (http://www.dynamicdrive.com/forums/showthread.php?p=207917)

VampireCoder
12-04-2009, 05:51 AM
Use This way to Right-Click Disabled...

In body tag of your page.. write oncontextmenu="return false".

For example,




<body oncontextmenu="return false"></body>

traq
12-04-2009, 02:17 PM
actually, that doesn't even work in Firefox 3 with javascript on. But if it works in your browser, why don't you try disabling javascript and seeing what happens?

amosngweien
12-19-2009, 12:09 AM
@traq - Put A Noscript Tag Around
<noscript><meta http-equiv="0; url=noscript" rel="NoScript" ></meta></noscript>
Once you do this, they will be redirected to http://yourdomain.com/noscript/
And Ask Them To On Javascript

amosngweien
12-20-2009, 05:37 PM
@VampireCoder - You Can Do That , But My Tutorial Does Not Use That

amosngweien
12-20-2009, 06:02 PM
@traq - Good Idea,
Might Do This


<!--[if it IE] -->
No Not IE!
<![end if]-->

LOL
Your Site Like This Won't Allow IE


<!--[if Firefox 1]-->
I DO NOT ALLOW OLD PEOPLE COME!
GO HAVE 100 BIRTHDAYS LA!
<![end if]-->
<!--[if Firefox 2]-->
I DO NOT ALLOW OLD PEOPLE COME!
GO HAVE 100 BIRTHDAYS LA!
<![end if]-->

LOL!!!!!!
Ermm,
Ask Them Upgrade Java Maybe.

traq
12-20-2009, 07:07 PM
...?
I'm not quite sure what you're trying to do there.

<!--[if it IE] -->
No Not IE!
<![end if]-->
lt (not it ) means "less than", e.g. if lt IE 6 means "if less than (earlier version than) IE 6". it won't work without the version number. If you want any version, just write if IE.

<!--[if Firefox 1]-->
I DO NOT ALLOW OLD PEOPLE COME!
GO HAVE 100 BIRTHDAYS LA!
<![end if]-->
<!--[if Firefox 2]-->
I DO NOT ALLOW OLD PEOPLE COME!
GO HAVE 100 BIRTHDAYS LA!
<![end if]-->
Only works in internet explorer. Firefox doesn't read conditional comments at all.


<noscript><meta http-equiv="0; url=noscript" rel="NoScript" ></meta></noscript>
FireFox lets me disable meta redirects as well.

Ask Them Upgrade Java[script?] Maybe.
Well, if they have to do it voluntarily anyway, why not just *ask* them not to right-click? There's no real point in trying to prevent it.