2011-08-15 36 views
1

下面是我想要改變的代碼,當我點擊jQuery按鈕?改變facebook點擊按鈕時打開圖形協議值

<head> 
    <title>The Rock (1996)</title> 
    <meta property="og:title" content="The Rock"/> 
    <meta property="og:type" content="movie"/> 
    <meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/> 
    <meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/> 
    <meta property="og:site_name" content="IMDb"/> 
    <meta property="fb:admins" content="USER_ID"/> 
    <meta property="og:description" 
      content="A group of U.S. Marines, under command of 
        a renegade general, take over Alcatraz and 
        threaten San Francisco Bay with biological 
        weapons."/> 
    ... 
    </head> 

我有一個問題,如果有可能使這個時候分享按鈕點擊上的Open Graph協議的變化值將共享鏈接得到什麼?

回答

0

您是否嘗試訪問馬塔標籤是這樣的:

$('meta[property=og:title]').attr("content", "new content"); 
$('meta[property=og:type]').attr("content", "new content"); 

等..?

$(element).bind("click", function(){ 
    $('meta[property=og:title]').attr("content", "new content"); 
    $('meta[property=og:type]').attr("content", "new content"); 
    // .... 
    // Do share action 
}); 
+0

感謝您的代碼它確實工作,當我查看源代碼,但是當我點擊共享它發送舊的開放圖形協議看起來這是Facebook緩存問題在這.. ..有可能做更改打開圖形協議值上分享按鈕上的時間? – idontknowhow

2

使用JavaScript更改這些內容不會改變在Facebook上顯示的內容。 Facebook的檢索這些值的方法將忽略頁面上的任何JavaScript並解析源代碼中的任何內容。

+0

我想也沒有其他方法可以改變Facebook上的開放圖標籤(&c:o)在單頁面應用上的不同網址? –