رفتن به مطلب

کد right-click در سند html با استفاده از جاوا اسکریپت


پست های پیشنهاد شده


<script>
document.onmousedown=disable; //IE
function disable(e)
{
if (e == null)
{ //IE disable
e = window.event;
if (e.button==2)
{
window.location='p3.html';
return false;
}
}
document.onclick=ffdisable; //FF
}
function ffdisable(e)
{
if (e.button==2)
{ //firefox disable
e.preventDefault();
e.stopPropagation();
window.location='p3.html';
return false;
}
}
</script>

  • امتیاز 4
لینک به ارسال

راحت ترین راحش اینه که لایه تون رو بسازید و برای یک فانکشن در حالت موس اور تعریف کنید و این کد را مقدار آن فانکشن بگذارید

مانند


<script>
function rightclick()
{
document.onmousedown=disable; //IE
function disable(e)
{
if (e == null)
{ //IE disable
e = window.event;
if (e.button==2)
{
window.location='p3.html';
return false;
}
}
document.onclick=ffdisable; //FF
}
function ffdisable(e)
{
if (e.button==2)
{ //firefox disable
e.preventDefault();
e.stopPropagation();
window.location='p3.html';
return false;
}
}}
</script>
<style type="text/css">
#tst {
width:600px;
height:600px;
}
table{
min-height:700px;
}
td{
border:thin #999966 solid;
}
</style>
<table align="center" cellpadding="13" cellspacing="0" style="width: 100%; height: 100%">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td id="tst" onmouseover="rightclick()"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>

  • امتیاز 4
لینک به ارسال

لطفا برای ارسال دیدگاه وارد شوید

شما بعد از اینکه وارد حساب کاربری خود شدید می توانید دیدگاهی ارسال کنید



ورود به حساب کاربری
×
×
  • اضافه کردن...