2013-06-05 59 views
2

我在ASP.NET中有一個網站,當人們訪問該網站時,會彈出一個小Cookie。我不想做的是複製這個,但對於經典ASP(不是我的錯誤)編寫的網站我知道代碼的作品,因爲它在當前網站上工作。我如何參考JavaScript以及它與頁面相關的地方?如果我的問題看起來很愚蠢,我對這一切都很陌生。預先感謝您的幫助。這是我使用的代碼:將JavaScript添加到經典ASP(新增功能)

DIV ID爲 「cookieConsentRequest」 RUNAT = 「服務器」 可見=「真

  <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>--> 

對不起它的國家

+2

你是什麼意思的「參考Java」? – ulluoink

+1

也許你應該展示你如何在.net中做這件事,以使事情更清晰。 – SearchAndResQ

+0

你的意思是用來創建cookie的JavaScript?這與傳統的ASP和ASP.NET完全相同,只是將它放在'.asp'頁面本身的''部分。 –

回答

1

JavaScript是一種部分您提供了您希望瀏覽器以HTML格式運行的JavaScript,或HTML中引用的.js文件。

jQuery引用their website是一個「快速,小而且功能豐富的JavaScript庫。這讓事情變得像HTML文檔遍歷和處理,事件處理,動畫和Ajax和一個易於使用的API,跨瀏覽器的許多作品更加簡單」。

重要的是,jQuery提供了$語法和cssslideDownfadeUp等功能代碼使用。

因此您的代碼必須引用jQuery庫。這很容易通過添加以下行之前完成(在<head>是確定的,但不一定是最好的做法)任何的你的jQuery代碼(JavaScript使用$jQuery):

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

這增加了對其最新(發佈時)託管在其服務器上的jQuery代碼的引用。您也可以在本地參考download the library here

+0

謝謝,這種幫助。 (我添加了頁面加載事件來檢查並打開新窗口),但它仍然不會呈現。我拉了所有的CSS通過,圖片等..... –

+0

請詳細解釋。 JSFIddle也可以提供幫助。 – jaypeagi

+0

不知道什麼是對不起。如果你去這個網站 - > http://www.claremont.im,那麼在底部顯示的小cookie警告就是這個腳本的來源。當放入ASP頁面時,文本顯示(分成9行),但它不會出現在小框或任何內容中,只是位於頁面的底部。 –