gpt4 book ai didi

javascript - 将 JavaScript 添加到经典 ASP(这是新的)

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

我在 ASP.NET 中有一个网站,当人们访问该网站时,会有一个小的 cookie 弹出警告。我不想做的是复制这个但是对于一个用经典 ASP 编写的站点(不是我的错)我知道代码有效,因为它在当前站点上有效。我如何引用 JavaScript 以及它与页面相关的位置?我对这一切真的很陌生,如果我的问题看起来真的很愚蠢,我很抱歉。在此先感谢您的帮助。这是我正在使用的代码:

div id="cookieConsentRequest"runat="server"visible="true

            <p><span class="queryIcon"></span>some text here                <a href="#" class="acceptCookiesAnchor acceptCookieSmall acceptCookie" runat="server">I accept</a>
<a href="Javascript:;" class="infoCookie" title="Tell me more about these cookies">Click here for more info</a>
<a href="Javascript:;" id="alertBannerHide" class="hideButton" title="Hide this">Hide</a>
</p>
</div>
<!--[if IE 6]>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('.alertBanner').css("top", ($(window).height() - 29));
});
</script>
<![endif]-->
<script type="text/javascript">
$(document).ready(function () {
$('.alertBanner').css("left", (($(window).width() / 2) - 360));
$('.alertBanner').delay(1000).slideDown('slow');
$('#alertBannerHide, a.denyCookie').click(function () {
$('.alertBanner').slideUp('slow');
$('.cookieInfoWindow').fadeOut('fast');
});
$('.cookieInfoWindow').css("left", (($(window).width() / 2) - 320));
$('a.acceptCookie, .infoCookie').click(function () {
$('.cookieInfoWindow').fadeIn('fast');
});
$('#cookieInfoWindowHide, .cookieInfoWindow a.denyCookie').click(function () {
$('.cookieInfoWindow').fadeOut('fast');
$('.alertBanner').slideUp('slow');
});
});
</script>
<div class="cookieInfoWindow">
<h3><a href="Javascript:;" id="cookieInfoWindowHide" class="hideButton" title="Hide this">Hide</a>Cookies used on this web site</h3><br />

<p>some text here</p><br />
<p>some text here <a href="http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55539" class="externalLinkWhite"
title="Read more about Google Analytics (external link)">Google Analytics</a> some text here.</p><br />
<p>some text herep><br />
<p>For more information on how cookies are used please visit the following websites:</p>
<ul>
<a href="http://www.microsoft.com/info/cookies.mspx" class="externalLinkWhite" title="Information about cookies on Microsoft.com (external link)">Microsoft Cookie Information</a><br /><br />
<a href="http://www.allaboutcookies.org/" class="externalLinkWhite" title="All about computer cookies (external link)">All About Cookies</a>
</ul>
<p>
<a id="acceptCookiesAnchor" href="#" class="acceptCookie" runat="server">Yes, I accept the use of cookies as outlined above</a>
</p>
</div>
</div>-->

对现在的状态感到抱歉。

最佳答案

JavaScript 是浏览器的一部分。您提供希望浏览器与 HTML 内联运行或作为 .js 运行的 JavaScript。 HTML 中引用的文件。

jQuery,引用 their website , 是“一个快速、小巧且功能丰富的 JavaScript 库。它使 HTML 文档遍历和操作、事件处理、动画和 Ajax 等事情变得更加简单,并通过一个易于使用的 API 跨多种浏览器工作” .

重要的是,jQuery 提供了 $语法和 css , slideDown , fadeUp等您的代码使用的函数。

因此您的代码必须引用 jQuery 库。这很容易通过在任何 jQuery 代码(使用 <head>$ 的 JavaScript)之前添加以下行(在 jQuery 中是可以但不一定是最佳实践)来轻松完成:

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

这添加了对其服务器上托管的最新(发布时)jQuery 代码的引用。您也可以download the library here并在本地引用。

关于javascript - 将 JavaScript 添加到经典 ASP(这是新的),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16936785/

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