在 asp.net 图表图像中禁用右键单击选项
disable right click option in asp.net chart image
我们的 Web 应用程序中有一个 asp.net 饼图。我们需要禁用该图表图像的右键单击选项。谁能告诉我如何禁用 asp.net 图表图像的右键单击选项。
我建议你 - 将你的 Pie
图表放入一个 <div></div>
和 disable
right click
<div>
如下代码
HTML
<div id="clickID" style="height:250px;width:180px;border:1px solid black;">
Here Your Pie Chart
</div>
JQuery
$(document).ready(function(){
$("#clickID").bind("contextmenu", function(e) {
e.preventDefault();
});
});
You can See Working JsFiddle Here
查看更新后的 Link Here
你当然可以做到这一点,但你必须附加一个与你想象的不同的事件。这是一个简单的例子,说明它的原理。
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script type="text/javascript">
function preventClick(e, showAlerts) {
if (e.which <= 3 && e.which >= 1) {
if (showAlerts) {
switch (e.which) {
case 1: alert('Left click'); break;
case 2: alert('Middle click'); break;
case 3: alert('Right click'); break;
}
} else {
//keeps the event from propagating
e.preventDefault()
}
}
}
</script>
<!--Change the second parameter to false to prevent propagation-->
<input type="button" onmousedown="preventClick(event, true)" />
我们的 Web 应用程序中有一个 asp.net 饼图。我们需要禁用该图表图像的右键单击选项。谁能告诉我如何禁用 asp.net 图表图像的右键单击选项。
我建议你 - 将你的 Pie
图表放入一个 <div></div>
和 disable
right click
<div>
如下代码
HTML
<div id="clickID" style="height:250px;width:180px;border:1px solid black;">
Here Your Pie Chart
</div>
JQuery
$(document).ready(function(){
$("#clickID").bind("contextmenu", function(e) {
e.preventDefault();
});
});
You can See Working JsFiddle Here
查看更新后的 Link Here
你当然可以做到这一点,但你必须附加一个与你想象的不同的事件。这是一个简单的例子,说明它的原理。
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script type="text/javascript">
function preventClick(e, showAlerts) {
if (e.which <= 3 && e.which >= 1) {
if (showAlerts) {
switch (e.which) {
case 1: alert('Left click'); break;
case 2: alert('Middle click'); break;
case 3: alert('Right click'); break;
}
} else {
//keeps the event from propagating
e.preventDefault()
}
}
}
</script>
<!--Change the second parameter to false to prevent propagation-->
<input type="button" onmousedown="preventClick(event, true)" />