解决方案 2012 年 8 月 9 日 9:54 EDT
令人尴尬的是,我们能够追踪浏览器设置的问题。活动脚本被禁用。感谢所有发帖的人。我感谢您的时间和精力。~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我最近开始开发一个新的 MVC3 应用程序,我们使用的是 jQuery 1.7.2。目前我们的代码适用于 Chrome、Firefox 和 IE7 & 9。不幸的是它不适用于 IE8。我们尝试使用什么 jQuery 函数(鼠标悬停、鼠标悬停、悬停、单击等)并不重要。
到目前为止,我已经尝试了以下方法,但没有任何运气。
- 使用对 jQuery 和 js 文件的绝对路径引用
- 将 js 代码直接移动到 _Layout.cshtml
- 验证类型=“文本/javascript”
- 将代码简化为 Alert("any text"); 并在备用浏览器中验证
- 添加背景颜色
- 删除对“Menu.js”的引用以测试 Shared.js 中非常简单的代码是否有效
我试图让 .hover 动作在 _ActionItems 部分视图上工作。用于此的 jQuery 在 Menu.js 中。我想如果我能让它工作,其余的可能会有一个我能想出的类似解决方案。
如果您还有什么需要看的,请告诉我。在此先感谢您的帮助。
_Layout.cshtml
@using eRecruitBoard.ExtensionMethods
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>@ViewBag.Title</title>
<link href='http://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic' rel='stylesheet' type='text/css'/>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.7.2.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Shared.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Menu.js")" type="text/javascript"></script>
</head>
<body>
<div class="wrapper">
<div class="aboveHeader">
<div class="aboveHeaderLeft">@Html.Partial("_ERBLogo")</div>
<div class="aboveHeaderRight">
<div class="ERBESBButtons">@Html.Partial("_ERBESBButtons")</div>
<div class="welcome">@Html.Partial("_Welcome")</div>
</div>
</div>
<div class="headerBar">
<div class="headerActions">@Html.Partial("_ActionItems")</div>
<div class="headerMenu">@Html.Action("Menu", "Menu")</div>
<div class="headerTitle">@Html.Action("HeaderTitle","Segment")</div>
</div>
<div class="content">
@RenderBody()
</div>
<div class="Push"></div>
</div>
<div class="footerWrapper">
<div class="footer">
<div class="footerLeft"></div>
<div class="footerRight"></div>
<div class="footerRightContent">@Html.ActionLink("Privacy Policy", "PrivacyPolicy", "Home")</div>
<div class="footerLeftContent">© Copyright 2012 - All Rights Reserved</div>
</div>
</div>
</body>
</html>
_ActionItems.cshtml
@if (eRecruitBoard.WebLibrary.CommonFunctions.IsAuthenticated)
{
@Html.ImageActionLink("../../Images/Header/FavoriteIcon.png", "FavoritesIcon", "Add", "Favorites", null, null, new { @class = "over", title="Add to favorites", style="border:0;" })<text> </text>
<img src="../../Images/Header/CalendarIcon.png" title="Schedule this report" alt="CalendarIcon" class="over"/><text> </text>
<img src="../../Images/Header/EmailIcon.png" title="Email this report" alt="EmailIcon" class="over"/><text> </text>
<img src="../../Images/Header/PrintIcon.png" title="Print" alt="PrintIcon" class="over"/>
}
else
{
}
Shared.js
// Hover image
$(document).ready(function () {
$(function () {
$("img.over").each(function () {
var t = $(this);
var src1 = t.attr("src"); // initial src
var newSrc = src1.substring(0, src1.lastIndexOf(".")); // let's get file name without extension
t.hover(function () {
$(this).attr("src", newSrc + "Over." + /[^.]+$/.exec(src1)); //last part is for extension
}, function () {
$(this).attr("src", newSrc + "." + /[^.]+$/.exec(src1)); //removing 'Over' from the name
});
});
});
});
更新- 我删除了 menu.js 代码,所以我可以添加浏览器源代码。我现在专注于 Shared.js 代码,因为它非常简单,即使 Menu.js 被完全删除也不会导致任何操作。
浏览器源代码示例- 请注意,这是我正在运行的测试之一,我将 jQuery 直接移动到页面上并添加了警报。无论如何,这也不起作用。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>eRecruitBoard</title>
<link href='http://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic' rel='stylesheet' type='text/css'/>
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-1.7.2.js" type="text/javascript"></script>
<script type="text/javascript">
// Hover image
$(document).ready(function () {
$(function () {
$("#container").hover('',function(){
alert("Out");
});
});
});
$(document).ready(function () {
$(function () {
$("img.over").each(function () {
var t = $(this);
var src1 = t.attr("src"); // initial src
var newSrc = src1.substring(0, src1.lastIndexOf(".")); // let's get file name without extension
t.hover(function () {
$(this).attr("src", newSrc + "Over." + /[^.]+$/.exec(src1)); //last part is for extension
}, function () {
$(this).attr("src", newSrc + "." + /[^.]+$/.exec(src1)); //removing 'Over' from the name
});
});
});
});
</script>
</head>
<body>
<div class="wrapper">
<div class="aboveHeader">
<div class="aboveHeaderLeft"><a href="/"><img alt="eRecruitBoard" src="../../Images/eRecruitBoardLogo.png" style="border:0;" /></a></div>
<div class="aboveHeaderRight">
<div class="ERBESBButtons"><img src="../../Images/Header/ERBOn.png" alt="eRecruitBoard On"/><img src="../../Images/Header/ESBOff.png" alt="eScoreBoard Off"/>
</div>
<div class="welcome">Welcome Firstname Lastname
<a href="/Admin/MyTeam">Admin</a> |
<a href="/Home/Logout">Logout</a></div>
</div>
</div>
<div class="headerBar">
<div class="headerActions"><a href="/Favorites/Add"><img alt="FavoritesIcon" class="over" src="../../Images/Header/FavoriteIcon.png" style="border:0;" title="Add to favorites" /></a>
<img src="../../Images/Header/CalendarIcon.png" title="Schedule this report" alt="CalendarIcon" class="over"/>
<img src="../../Images/Header/EmailIcon.png" title="Email this report" alt="EmailIcon" class="over"/>
<img id="container" src="../../Images/Header/PrintIcon.png" title="Print" alt="PrintIcon" class="over"/>
</div>
<div class="headerMenu"><img src="../../Images/Header/MenuIcon.png" id="MenuIcon" title="Click to open the menu" alt="MenuIcon" class="over"/>
<table class="menuTable" id="menuTableId" cellspacing="0" cellpadding="0">
<thead>
<tr class="scrollUpArrow">
<th>
</th>
</tr>
</thead>
<tfoot>
<tr class="scrollDownArrow">
<td>
</td>
</tr>
</tfoot>
<tbody id="contents" class="tablebody" style="overflow:hidden">
<tr class="trmenuClass" id=favoritestrId>
<td class="cellBackground">
<div class="minusSign" id=favoritesMinusSignId>
<div class=favIcon id=divFavoritesid>
<div class="cellName">
Favorites
</div>
</div>
</div>
</td>
</tr>
<tr class="favtrClass" id="submenufavouritestrId">
<td class="subMenuCell" id="idFavorites">
<div class="subMenuCellName">
1st name
</div>
</td>
</tr>
<tr class="favtrClass" id="submenufavouritestrId">
<td class="subMenuCell" id="idFavorites">
<div class="subMenuCellName">
2nd name
</div>
</td>
</tr>
<tr class="favtrClass" id="submenufavouritestrId">
<td class="subMenuCell" id="idFavorites">
<div class="subMenuCellName">
3rd name
</div>
</td>
</tr>
<tr class="trmenuClass" id=dashboardtrId>
<td class="cellBackground">
<div class="minusSign" id=dashboardMinusSignId>
<div class=dashboardIcon id=divDashBoardid>
<div class="cellName">
Dashboard
</div>
</div>
</div>
</td>
</tr>
<tr class="dashboardtrClass" id="submenudashboardtrId">
<td class="subMenuCell" id="idDashboard">
<div class="subMenuCellName">
Dashboard Item 1
</div>
</td>
</tr>
<tr class="dashboardtrClass" id="submenudashboardtrId">
<td class="subMenuCell" id="idDashboard">
<div class="subMenuCellName">
Dashboard Item 2
</div>
</td>
</tr>
<tr class="dashboardtrClass" id="submenudashboardtrId">
<td class="subMenuCell" id="idDashboard">
<div class="subMenuCellName">
Dashboard Item 3
</div>
</td>
</tr>
<tr class="trmenuClass" id=connecttrId>
<td class="cellBackground">
<div class="minusSign" id=connectMinusSignId>
<div class=connectIcon id=divConnectid>
<div class="cellName">
Connect
</div>
</div>
</div>
</td>
</tr>
<tr class="connecttrClass" id="submenuconnecttrId">
<td class="subMenuCell" id="idConnect">
<div class="subMenuCellName">
Joe Smith
</div>
</td>
</tr>
<tr class="connecttrClass" id="submenuconnecttrId">
<td class="subMenuCell" id="idConnect">
<div class="subMenuCellName">
Erin Jones
</div>
</td>
</tr>
<tr class="connecttrClass" id="submenuconnecttrId">
<td class="subMenuCell" id="idConnect">
<div class="subMenuCellName">
Owen Alexander
</div>
</td>
</tr>
<tr class="trmenuClass" id=hiretrId>
<td class="cellBackground">
<div class="minusSign" id=hireMinusSignId>
<div class=hireIcon id=divHireid>
<div class="cellName">
Hire
</div>
</div>
</div>
</td>
</tr>
<tr class="hiretrClass" id="submenuhiretrId">
<td class="subMenuCell" id="idHire" >
<div class="subMenuCellName">
Clair Brown
</div>
</td>
</tr>
<tr class="trmenuClass" id=retaintrId>
<td class="cellBackground">
<div class="minusSign" id=retainMinusSignId>
<div class=retainIcon id=divRetainid>
<div class="cellName">
Retain
</div>
</div>
</div>
</td>
</tr>
<tr class="retaintrClass" id="submenuretaintrId">
<td class="subMenuCell" id="idRetain">
<div class="subMenuCellName">
some good employee name
</div>
</td>
</tr>
<tr class="trmenuClass" id=activityreportstrId>
<td class="cellBackground">
<div class="minusSign" id=activityreportsMinusSignId>
<div class=activityIcon id=divActivityReportsid>
<div class="cellName">
Activity Reports
</div>
</div>
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 1
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 2
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 3
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 4
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 5
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 6
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 7
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 8
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 9
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 10
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 11
</div>
</td>
</tr>
<tr class="activityreportstrClass" id="submenuactivityreportstrId">
<td class="subMenuCell" id="idActivityReports">
<div class="subMenuCellName">
Activity report 12
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="headerTitle"><img src="../../Images/Header/TitleArrow.png" alt="Arrow" style="vertical-align:top;"/>
<ul class="segmentControl">
</ul>
</div>
</div>
<div class="content">
<h2>Homepage</h2> - <a href="/Dashboard/All">Link to Dashboard/All</a>
</div>
<div class="Push"></div>
</div>
<div class="footerWrapper">
<div class="footer">
<div class="footerLeft"></div>
<div class="footerRight"></div>
<div class="footerRightContent"><a href="/Home/PrivacyPolicy">Privacy Policy</a></div>
<div class="footerLeftContent">© Copyright 2012 - All Rights Reserved</div>
</div>
</div>
</body>
</html>