1
我將FaceBook Likebutton,Google +1按鈕和Twitter按鈕添加到MasterPage.master,並讓這些 按鈕顯示在我的所有網頁上。在Asp.net 4.0中,如何才能延遲加載FaceBook,Google +1按鈕代碼?
我的IPS塊FaceBook,Google和Twitter,所以default.aspx顯示速度很慢,因爲網頁必須等待加載FaceBook,Google +1按鈕代碼完全。
這是一種延遲加載FaceBook,Google +1按鈕代碼並首先顯示內容default.aspx的方法嗎?
您可以在http://dl.dropbox.com/u/209352/WebSite2.zip
==============================Default.aspx====================
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
=========================MasterPage.master===================================
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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 runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div class="fb-like" data-href="http://www.myweb.com" data-send="false" data-layout="button_count"
data-width="120" data-show-faces="false" data-font="verdana">
</div>
<div>
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.supercoolbookmark.com/"
data-count="horizontal" data-via="mycwcgr">Tweet</a><script type="text/javascript"
src="//platform.twitter.com/widgets.js"></script>
</div>
<div>
<g:plusone size="medium"></g:plusone>
</div>
<div>
<p>Hello, the world!</p>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
<div id="fb-root"></div>
<script> (function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));</script>
<!-- Place this render call where appropriate -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</body>
</html>
謝謝!你能寫一些示例代碼嗎? – HelloCW
你看過我提供的兩個jQuery鏈接嗎?他們在其中有示例代碼。 – mjwills