Right_Click上下文菜单在IE7中不起作用..... [英] Right_Click Context Menu not working in Ie7.....
本文介绍了Right_Click上下文菜单在IE7中不起作用.....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在上下文菜单中使用了Java脚本,它在firefox.chrome ...中工作正常,但是在ie7中却无法工作.
这是我的编码
I used java script for context menu it well work in firefox.chrome....but not work in ie7..pls help me
here is my coding
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ContextMenu.aspx.cs" Inherits="RightClickMenu.ContextMenu" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script> <script src="http://labs.abeautifulsite.net/archived/jquery-contextMenu/demo/jquery.contextMenu.js" type="text/javascript"></script> <link href="http://labs.abeautifulsite.net/archived/jquery-contextMenu/demo/jquery.contextMenu.css" rel="stylesheet" type="text/css" />
<%--<link href="SampleScripts/Menu.css" rel="Stylesheet" type="text/css" />--%>
<script type="text/javascript">
$(document).ready(function () {
// $("input:text").focus(function () { $(this).select(); });
$("#<%= txtEnterUrl.ClientID%>").contextMenu({
menu: 'myMenu'
}, function (action, el, pos) {
contextMenuWork(action, el, pos);
});
});
function contextMenuWork(action, el, pos) {
ShowSelection(selectedText);
switch (action) {
case "Name":
{
document.getElementById('<%= txtName.ClientID %>').value = selectedText;
break;
}
case "Number":
{
ValidationNumber(selectecText);
if (selectedText) {
document.getElementById('<%= txtNumber.ClientID %>').value = selectedText;
}
break;
}
case "Address":
{
document.getElementById('<%= txtAddress.ClientID %>').value = selectedText;
break;
}
case "Country":
{
document.getElementById('<%= txtCountry.ClientID %>').value = selectedText;
break;
}
}
function ShowSelection(selectedText) {
var textComponent = document.getElementById("<%= txtEnterUrl.ClientID%>");
var selectedText;
if (document.selection != undefined) {
textComponent.focus();
var sel = document.selection.createRange();
selectedText = sel.text;
}
else if (textComponent.selectionStart != undefined) {
var startPos = textComponent.selectionStart;
var endPos = textComponent.selectionEnd;
selectedText = textComponent.value.substring(startPos, endPos);
return selectedText;
}
}
function validaitionNumber(selectedText) {
var numbers = /^[0-9]+$/;
if (numbers.test(selectedText)) {
return selectedText;
}
else {
alert("Only Accept Numbers");
textComponent.focus();
}
}
</script>
</head>
<body>
<ul id="myMenu" class="contextMenu">
<li id="Name"><a href="#Name">Name</a></li>
<li id="Number"><a href="#Number">Number</a></li>
<li id="Address"><a href="#Address">Address</a></li>
<li id="Country"><a href="#Country">Country</a></li>
</ul>
<form id="form1" runat="server">
<table style="width:100%; height:411px;">
<tr>
<td style="width:100%; height:20%" bgcolor="#000066">
<asp:Label ID="lblEnterUrl" runat="server" Text="TEXT AREA" Font-Bold="True"
style="z-index: 1; left: 271px; top: 66px; position: absolute"
Font-Size="X-Large" ForeColor="White" ></asp:Label>
<asp:TextBox ID="txtEnterUrl" runat="server" TextMode ="MultiLine"
style="z-index: 1; left: 405px; top: 51px; position: absolute; width: 505px; height: 47px" ></asp:TextBox>
</td>
</tr>
<tr>
<td style="width:100%; height:80%" bgcolor="#CCCCFF">
<asp:Label ID="lblName" runat="server" Text="Name"
style="z-index: 1; left: 278px; top: 161px; position: absolute; right: 526px;"
Font-Bold="True"></asp:Label>
<asp:TextBox ID="txtName" runat="server"
style="z-index: 1; left: 376px; top: 159px; position: absolute" ReadOnly="True" ></asp:TextBox>
<asp:TextBox ID="txtNumber" runat="server"
style="z-index: 1; left: 375px; top: 256px; position: absolute" ReadOnly="True"></asp:TextBox>
<asp:Label ID="lblAddress" runat="server" Text="Address"
style="z-index: 1; left: 585px; top: 160px; position: absolute; height: 19px; width: 64px"
Font-Bold="True"></asp:Label>
<asp:TextBox ID="txtAddress" runat="server"
style="z-index: 1; left: 707px; top: 158px; position: absolute" ReadOnly="True" ></asp:TextBox>
<asp:Label ID="lblCountry" runat="server" Text="Country"
style="z-index: 1; left: 584px; top: 259px; position: absolute" Font-Bold="True"></asp:Label>
<asp:TextBox ID="txtCountry" runat="server"
style="z-index: 1; left: 713px; top: 261px; position: absolute" ReadOnly="True" ></asp:TextBox>
<asp:Label ID="lblNumber" runat="server" Text="Number"
style="z-index: 1; left: 275px; top: 256px; position: absolute" Font-Bold="True"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</html>
推荐答案
(文档).ready( function (){ //
(document).ready(function () { //
("input:text").focus(function() {
("input:text").focus(function () {
(this).select();});
(this).select(); });
这篇关于Right_Click上下文菜单在IE7中不起作用.....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文