2012-12-20 67 views
0

我目前在概要Web部件視圖中的主頁上有外部網站鏈接列表。這些鏈接包括谷歌,公司的網站,報紙網站等。而不是Sharepoint使用的子彈點(square.gif),我需要鏈接到的網站的實際徽標。在Sharepoint中覆蓋square.gif

我已經嘗試添加像'類型'的列,但它只是顯示一個圖像,說它鏈接到另一個網頁,我不想。

我碰到這個thread: 的最後答案看起來像是我可以使用:

<script language="javascript" type="text/javascript"> 
    var arrElements = document.getElementsByTagName("img"); 
    for (var i=0; i<arrElements.length; i++) { 
      //get pointer each image element: 
      var element=arrElements[i]; 
      //check for a source with /images/square.gif from this site: 
      if (element.getAttribute('src') == 
         "http://www.MY-SITE-NAME.com/_layouts/images/square.gif") { 
       //found... change it's src to our new image: 
       element.setAttribute('src', 'http://www.MY-SITE-NAME.com/MY-LOCATION/MY-CUSTOM-BULLET.gif'); 
      } 
     } 
</script> 

我需要改變的地方設置每個點於同一畫面,以JavaScript的看着每一個網站和檢索徽標縮略圖(類似於瀏覽器頂部標籤中的小圖片)。

回答

0

我相信你需要jQuery的力量。這應該帶你進了一步:

<html> 
<head> 
    <title> New Document </title> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
    <script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script> 
</head> 

<body> 
<ul id="myList"> 
    <li><a href="http://www.google.gr">google</a></li> 
    <li><a href="http://news.in.gr">in news</a></li>  
    <li><a href="http://www.star.gr">star</a></li> 
</ul> 
<script type="text/javascript"> 
$('#myList li').each(function() { 
    var href = $(this).children("a").prop("href"); 
    var discImage = "url('" + href + "favicon.ico')"; 
    // alert(discImage); 
    $(this).css("list-style-image", discImage); 
}); 
</script> 
</body> 
</html> 

的圖標是(可能)的唯一圖像在所有網站使用同一個名稱,但並不總是相同的尺寸(檢查谷歌的一個舉例)。

現場演示 - >http://jsfiddle.net/Mt7XA/享受!