你要实现的是在网页上点击右键弹出的菜单吗?那必须用客户端脚本实现,在vs.net中当然也可以编辑客户端脚本,但代码得自己写。
解决方案 »
- ASP.NET页面事件无法执行
- .net 在一处 设置全网站的缓存,怎么设置,在哪里写呢
- DATAGRID点两次才可进入编辑状态?
- (ASP.NET)中TeeChart控件的使用问题?
- 用js或者css该怎样去掉html中的一段代码???
- 在web应用程序中,如何取得dataset中当前的数据是第几行吗,如何在dataset中的当前行移动到下一行或上一行?
- 判断字段是否为空,出现问题,大家帮忙
- 求一个像写邮件的文本编辑器,要有表情选择,可选背景信纸,其它还有一些基本功能就行
- 使用CODE FIRST能否在创建数据库的表时默认给该表添加一些默认数据?
- 菜鸟之提
- 如何得到访问者的ip,初学者提问?
- Label2.Text= Request.UserHostAddress.ToString().Trim();为什么得到的都是127.0.0.1呢?我明明有一个动态IP呀?
我复制了一段JS的代码:
<!--将以下代码加入HTML的<Body></Body>之间-->
<style>
<!--
.skin0 {
position:absolute;
text-align:left;
width:200px;
border:2px solid black;
background-color:menu;
font-family:Verdana;
line-height:20px;
cursor:default;
visibility:hidden;
}
.skin1 {
cursor:default;
font:menutext;
position:absolute;
text-align:left;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
width:120px;
background-color:menu;
border:1 solid buttonface;
visibility:hidden;
border:2 outset buttonhighlight;
}
.menuitems {
padding-left:15px;
padding-right:10px;
}
-->
</style><SCRIPT LANGUAGE="JavaScript1.2">
<!-- Begin
var menuskin = "skin1";
var display_url = 0;
function showmenuie5() {
var rightedge = document.body.clientWidth-event.clientX;
var bottomedge = document.body.clientHeight-event.clientY;
if (rightedge < ie5menu.offsetWidth)
ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;
else
ie5menu.style.left = document.body.scrollLeft + event.clientX;
if (bottomedge < ie5menu.offsetHeight)
ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;
else
ie5menu.style.top = document.body.scrollTop + event.clientY;
ie5menu.style.visibility = "visible";
return false;
}
function hidemenuie5() {
ie5menu.style.visibility = "hidden";
}
function highlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "highlight";
event.srcElement.style.color = "white";
if (display_url)
window.status = event.srcElement.url;
}
}
function lowlightie5() {
if (event.srcElement.className == "menuitems") {
event.srcElement.style.backgroundColor = "";
event.srcElement.style.color = "black";
window.status = "";
}
}
function jumptoie5() {
if (event.srcElement.className == "menuitems") {
if (event.srcElement.getAttribute("target") != null)
window.open(event.srcElement.url, event.srcElement.getAttribute("target"));
else
window.location = event.srcElement.url;
}
}
// End -->
</script>
<div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5();">
<div class="menuitems" url="http://www.google.com#">google</div>
<div class="menuitems" url="http://www.skycn.com#">天空下载</div>
</div>
<script language="JavaScript1.2">
if (document.all && window.print) {
ie5menu.className = menuskin;
document.oncontextmenu = showmenuie5;
document.body.onclick = hidemenuie5;}
</script>结果点右键出现的是链接功能,但我需要的是其他功能,不知道在哪写代码了。谢谢了。
<div class="menuitems" url="http://www.skycn.com#">天空下载</div>url属性改为onclick=“函数名”