gpt4 book ai didi

Javascript 在 asp.net 母版页中没有做任何事情

转载 作者:行者123 更新时间:2023-11-28 09:20:25 28 4
gpt4 key购买 nike

我在向我的 asp.net 母版页添加照片幻灯片时遇到问题。我正在为我的一个 friend 做这个元素,她需要为她的公司建立一个网站。我尝试了许多不同的幻灯片放映,并使用教程从头开始编写一些代码。这不是我的主要语言,所以我发现很难准确地发现问题所在,并且尝试了所有可能的解决方案都没有成功,我决定寻求帮助。

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="WingtipToys.SiteMaster" %>

<!DOCTYPE html>

<html lang="en">
<head runat="server">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />


<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/modernizr") %>
</asp:PlaceHolder>
<webopt:bundlereference runat="server" path="~/Content/css" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<!--######################Slider Code Start###############################-->

<title>Featured Content Slider</title>

<link rel="stylesheet" type="text/css" href="~/FeaturedContentSlider/style.css" />

<script type="text/javascript" src="~/FeaturedContentSlider/js/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="~/FeaturedContentSlider/js/jquery-easing-1.3.pack.js"></script>
<script type="text/javascript" src="~/FeaturedContentSlider/js/jquery-easing-compatibility.1.2.pack.js"></script>
<script type="text/javascript" src="~/FeaturedContentSlider/js/coda-slider.1.1.1.pack.js"></script>

<script type="text/javascript">

var theInt = null;
var $crosslink, $navthumb;
var curclicked = 0;

theInterval = function (cur) {
clearInterval(theInt);

if (typeof cur != 'undefined')
curclicked = cur;

$crosslink.removeClass("active-thumb");
$navthumb.eq(curclicked).parent().addClass("active-thumb");
$(".stripNav ul li a").eq(curclicked).trigger('click');

theInt = setInterval(function () {
$crosslink.removeClass("active-thumb");
$navthumb.eq(curclicked).parent().addClass("active-thumb");
$(".stripNav ul li a").eq(curclicked).trigger('click');
curclicked++;
if (6 == curclicked)
curclicked = 0;

}, 3000);
};

$(function () {

$("#main-photo-slider").codaSlider();

$navthumb = $(".nav-thumb");
$crosslink = $(".cross-link");

$navthumb
.click(function () {
var $this = $(this);
theInterval($this.parent().attr('href').slice(1) - 1);
return false;
});

theInterval();
});
</script>
<!--######################Slider Code End###############################-->
</head>
<body>
<form runat="server">
<asp:ScriptManager runat="server">
<Scripts>
<%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="bootstrap" />
<asp:ScriptReference Name="respond" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</asp:ScriptManager>

<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" runat="server" href="~/">Wingtip Toys</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a runat="server" id="adminLink" visible="false"
href="~/Admin/AdminPage">Admin</a></li>
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/About">About</a></li>
<li><a runat="server" href="~/Contact">Contact</a></li>
<li><a runat="server" href="~/ProductList">Products</a></li>
<li><a runat="server" href="~/ShoppingCart" ID="cartCount">&nbsp;</a></li>
</ul>
<asp:LoginView runat="server" ViewStateMode="Disabled">
<AnonymousTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Register">Register</a></li>
<li><a runat="server" href="~/Account/Login">Log in</a></li>
</ul>
</AnonymousTemplate>
<LoggedInTemplate>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/Account/Manage" title="Manage your account">Hello, <%: Context.User.Identity.GetUserName() %> !</a></li>
<li>
<asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
</li>
</ul>
</LoggedInTemplate>
</asp:LoginView>
</div>
</div>
</div>

<!--######################Slider Code Start###############################-->
<div id="page-wrap">

<div class="slider-wrap">
<div id="main-photo-slider" class="csw">
<div class="panelContainer">

<div class="panel" title="Panel 1">
<div class="wrapper">
<img src="FeaturedContentSlider/images/tempphoto-1.jpg" alt="temp" />
<div class="photo-meta-data">
Photo Credit: <a href="http://flickr.com/photos/astrolondon/2396265240/">Kaustav Bhattacharya</a><br />
<span>"Free Tibet" Protest at the Olympic Torch Rally</span>
</div>
</div>
</div>
<div class="panel" title="Panel 2">
<div class="wrapper">
<img src="FeaturedContentSlider/images/tempphoto-2.jpg" alt="temp" />
<div class="photo-meta-data">
Chicago Bears at Seattle Seahawks<br />
<span>Fifth field goal, overtime win for the Seahawks</span>
</div>
</div>
</div>
<div class="panel" title="Panel 3">
<div class="wrapper">

<img src="FeaturedContentSlider/images/scotch-egg.jpg" alt="scotch egg" class="floatLeft"/>

<h1>How to Cook a Scotch Egg</h1>

<ul>
<li>6 hard-boiled eggs, well chilled</li>
<li>1 pound good quality sausage meat</li>
<li>1/2 cup AP flour</li>
<li>1-2 eggs, beaten</li>
<li>3/4 cup panko-style bread crumbs</li>
<li>Vegetable oil for frying</li>
</ul>
</div>
</div>
<div class="panel" title="Panel 4">
<div class="wrapper">
<img src="FeaturedContentSlider/images/tempphoto-4.jpg" alt="temp" />
<div class="photo-meta-data">
A Poem by Shel Silverstein<br />
<span>Falling Up</span>
</div>
</div>
</div>
<div class="panel" title="Panel 5">
<div class="wrapper">
<img src="FeaturedContentSlider/images/tempphoto-5.jpg" alt="temp" />
<div class="photo-meta-data">
New Video on CSS-Tricks<br />
<span>Using Wufoo for Web Forms</span>
</div>
</div>
</div>
<div class="panel" title="Panel 6">
<div class="wrapper">
<h1>A Tale of Two Cities</h1>
<p><em>Charles Dickins</em></p>
<blockquote>It was the best of times</blockquote>
</div>
</div>

</div>
</div>

<a href="#1" class="cross-link active-thumb"><img src="FeaturedContentSlider/images/tempphoto-1thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a>
<div id="movers-row">
<div><a href="#2" class="cross-link"><img src="FeaturedContentSlider/images/tempphoto-2thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a></div>
<div><a href="#3" class="cross-link"><img src="FeaturedContentSlider/images/tempphoto-3thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a></div>
<div><a href="#4" class="cross-link"><img src="FeaturedContentSlider/images/tempphoto-4thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a></div>
<div><a href="#5" class="cross-link"><img src="FeaturedContentSlider/images/tempphoto-5thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a></div>
<div><a href="#6" class="cross-link"><img src="FeaturedContentSlider/images/tempphoto-6thumb.jpg" class="nav-thumb" alt="temp-thumb" /></a></div>
</div>

</div>

</div>
<!--######################Slider Code End###############################-->
<div id="TitleContent" style="text-align: center">
<a runat="server" href="~/">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/logo.jpg" BorderStyle="None" />
</a>
<br />
</div>
<div id="CategoryMenu" style="text-align: center">
<asp:ListView ID="categoryList"
ItemType="WingtipToys.Models.Category"
runat="server"
SelectMethod="GetCategories" >
<ItemTemplate>
<b style="font-size: large; font-style: normal">
<a href="<%#: GetRouteUrl("ProductsByCategoryRoute", new {categoryName = Item.CategoryName}) %>">
<%#: Item.CategoryName %>
</a>
</b>
</ItemTemplate>
<ItemSeparatorTemplate> | </ItemSeparatorTemplate>
</asp:ListView>
</div>
<div class="container body-content">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
<hr />
<footer>
<p>&copy; <%: DateTime.Now.Year %> - Wingtip Toys</p>
</footer>
</div>
</form>
</body>
</html>

那么当前发生的情况是 Style.css 文件被访问,但似乎没有任何 javascript 文件在执行任何操作。显示了 slider ,但所有图像都垂直放置在彼此下方,因此我有一长行图像垂直向下延伸到页面下方。抱歉,如果格式不正确或没有足够的细节,这是我在这里的第一篇文章,我通常会自己解决问题。感谢您的帮助!!

编辑:

我从 javascript 路径中删除了 tilda“~”,并且似乎找到了 java 文件,当我按 F12 或“Ctrl + shift + j”时,我收到以下错误:“Uncaught typeError: undefined is not a function “在线:“$(“#main-photo-slider”).codaSlider();”

编辑 2:

我无法上传控制台输出的屏幕截图,因为我的声誉是惊人的 1 分,但在控制台输出中的 Frames->Default->Scripts 下列出了以下内容。

jquery-easing-compatibility.1.2.pack.js, jquery-easing-1.3.pack.js, jquery-1.2.6.min.js, coda-slider.1.1.1.pack.js, jquery-1.10.2.js, ycodaslider-2.0.pack.js,

这是 index.html 文件中有效的代码,当我尝试在我的 site.master 页面中执行相同的操作时它不起作用。

  <!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>Featured Content Slider</title>

<link rel="stylesheet" type="text/css" href="style.css" />

<script type="text/javascript" src="js/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="js/jquery-easing-1.3.pack.js"></script>
<script type="text/javascript" src="js/jquery-easing-compatibility.1.2.pack.js"></script>
<script type="text/javascript" src="js/coda-slider.1.1.1.pack.js"></script>

<script type="text/javascript">
var theInt = null;
var $crosslink, $navthumb;
var curclicked = 0;

theInterval = function(cur) {
clearInterval(theInt);

if (typeof cur != 'undefined')
curclicked = cur;

$crosslink.removeClass("active-thumb");
$navthumb.eq(curclicked).parent().addClass("active-thumb");
$(".stripNav ul li a").eq(curclicked).trigger('click');

theInt = setInterval(function() {
$crosslink.removeClass("active-thumb");
$navthumb.eq(curclicked).parent().addClass("active-thumb");
$(".stripNav ul li a").eq(curclicked).trigger('click');
curclicked++;
if (6 == curclicked)
curclicked = 0;

}, 3000);
};

$(function() {

$("#main-photo-slider").codaSlider();

$navthumb = $(".nav-thumb");
$crosslink = $(".cross-link");

$navthumb
.click(function() {
var $this = $(this);
theInterval($this.parent().attr('href').slice(1) - 1);
return false;
});

theInterval();
});
</script>
</head>

<body>

<div id="page-wrap">

<div class="slider-wrap">
<div id="main-photo-slider" class="csw">
<div class="panelContainer">

<div class="panel" title="Panel 1">
<div class="wrapper">
<img src="images/tempphoto-1.jpg" alt="temp" />
<div class="photo-meta-data">
Photo Credit: <a href="http://flickr.com/photos/astrolondon/2396265240/">Kaustav Bhattacharya</a>
<br />
<span>"Free Tibet" Protest at the Olympic Torch Rally</span>
</div>
</div>
</div>
<div class="panel" title="Panel 2">
<div class="wrapper">
<img src="images/tempphoto-2.jpg" alt="temp" />
<div class="photo-meta-data">
Chicago Bears at Seattle Seahawks
<br />
<span>Fifth field goal, overtime win for the Seahawks</span>
</div>
</div>
</div>
<div class="panel" title="Panel 3">
<div class="wrapper">

<img src="images/scotch-egg.jpg" alt="scotch egg" class="floatLeft" />

<h1>How to Cook a Scotch Egg</h1>

<ul>
<li>6 hard-boiled eggs firm up)</li>
<li>1 pound good quality</li>
<li>1/2 cup AP flour</li>
<li>1-2 eggs, beaten</li>
<li>3/4 cup panko-style bread crumbs</li>
<li>Vegetable oil for frying</li>
</ul>
</div>
</div>
<div class="panel" title="Panel 4">
<div class="wrapper">
<img src="images/tempphoto-4.jpg" alt="temp" />
<div class="photo-meta-data">
A Poem by Shel Silverstein
<br />
<span>Falling Up</span>
</div>
</div>
</div>
<div class="panel" title="Panel 5">
<div class="wrapper">
<img src="images/tempphoto-5.jpg" alt="temp" />
<div class="photo-meta-data">
New Video on CSS-Tricks
<br />
<span>Using Wufoo for Web Forms</span>
</div>
</div>
</div>
<div class="panel" title="Panel 6">
<div class="wrapper">
<h1>A Tale of Two Cities</h1>
<p><em>Charles Dickins</em>
</p>
<blockquote>It was the best of times, en, we were all going direct</blockquote>
</div>
</div>

</div>
</div>

<a href="#1" class="cross-link active-thumb">
<img src="images/tempphoto-1thumb.jpg" class="nav-thumb" alt="temp-thumb" />
</a>
<div id="movers-row">
<div>
<a href="#2" class="cross-link">
<img src="images/tempphoto-2thumb.jpg" class="nav-thumb" alt="temp-thumb" />
</a>
</div>
<div>
<a href="#3" class="cross-link">
<img src="images/tempphoto-3thumb.jpg" class="nav-thumb" alt="temp-thumb" />
</a>
</div>
<div>
<a href="#4" class="cross-link">
<img src="images/tempphoto-4thumb.jpg" class="nav-thumb" alt="temp-thumb" />
</a>
</div>
<div>
<a href="#5" class="cross-link">
<img src="images/tempphoto-5thumb.jpg" class="nav-thumb" alt="temp-thumb" />
</a>
</div>
<div>
<a href="#6" class="cross-link">
<img src="images/tempphoto-6thumb.jpg" class="nav-thumb" alt="temp-thumb" />
</a>
</div>
</div>

</div>

</div>

</body>

</html>

这是我尝试使用的 slider 的链接:http://css-tricks.com/creating-a-slick-auto-playing-featured-content-slider/ slider 附带的 index.html 有效。但我无法在我的 site.master 中使用相同的功能。

最佳答案

尝试使用不带“~”的脚本源。以“/”开头足以达到 HTML 的根目录。 "~"在服务器端可用。

关于Javascript 在 asp.net 母版页中没有做任何事情,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26115222/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com