我认为这个问题没有在其他地方提出过,但如果我错了,请纠正我。
我正在使用我在网上找到的一段漂亮的 javascript 代码来在页面上添加图像幻灯片。我已将它添加到 ASP.NET 页面,它工作正常,图像以适当的间隔正确显示。但是,问题是每当我刷新页面(F5 或地址栏上的“刷新”按钮,顺便说一下,我正在 IE9 上测试)时,都会出现此错误消息: Line: 17 Error: 'jQuery' is不明确的
后跟:第 44 行错误:属性“jQuery”的值为 null 或未定义,而不是 Function 对象。
当我转到另一个页面并单击“返回”按钮时,幻灯片也可以正常工作。似乎该问题仅发生在页面刷新时。
这是 ASP 标头内容标签中的代码:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="Scripts/fadeslideshow.js"></script>
幻灯片的代码取自“Dynamic Drive”(幻灯片中的终极淡入淡出 v2.0)http://www.dynamicdrive.com/
我尝试将 javascript 引用移动到 ASP 正文内容标记中的底部,以防错误与页面加载时调用 javascript 的顺序有关。虽然我真的没有什么想法,而且现在有点卡住了。任何帮助表示赞赏。
ASP.NET 页面的代码:
<%@ Page Title="Community Support" Language="VB" MasterPageFile="~/Main.Master" AutoEventWireup="false"
CodeFile="Copy of CommunitySupport.aspx.vb" Inherits="CommunitySupport" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="Scripts/fadeslideshow.js">
/***********************************************
* Ultimate Fade In Slideshow v2.0- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
<script type="text/javascript">
var defaultPhoto1 = new String("");
var defaultPhoto2 = new String("");
var defaultCaption1 = new String("");
var defaultCaption2 = new String("");
defaultCaption1 = "caption A";
defaultCaption2 = "caption B";
defaultPhoto1 = "Images/photo1.png";
defaultPhoto2 = "Images/photo2.png";
function getSlideShowImages() {
var mygallery = new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [320, 220], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
[defaultPhoto1, "", "", defaultCaption1],
[defaultPhoto2, "", "", defaultCaption2]
] //<--no trailing comma after very last image element!
,
displaymode: { type: 'auto', pause: 2500, cycles: 0, wraparound: false },
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "ondemand",
togglerid: ""
})
}
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:HiddenField ID="hidSlideShow" runat="server"/>
<asp:HiddenField ID="hidCaptions" runat="server"/>
<table width="100%">
<tr>
<td width="60%" valign="top">
<table width="100%">
<tr>
<td width="100%" valign="bottom" class="heading1">Title
</td>
</tr>
<tr>
<td width="100%"><br />Content
</td>
</tr>
<tr>
</tr>
</table>
</td>
<td width="40%" valign="top">
<div id="fadeshow1" class="slideDiv">
</div>
</td>
</tr>
</table>
“fadeshow1” div 是显示幻灯片的位置。