來自LinkedIn API的這一行示例代碼完美工作。如何調用LinkedIn從按鈕0123授權的javascript
<script type="IN/Login" data-onAuth="loadData"></script>
但它會在網頁加載時自動運行。我想使用網頁上的按鈕或鏈接調用此腳本。這個想法是,網頁加載並等待用戶準備好進行身份驗證。
理想情況下,我希望LinkedIn登錄圖像出現,然後等待,直到點擊。
謝謝。
來自LinkedIn API的這一行示例代碼完美工作。如何調用LinkedIn從按鈕0123授權的javascript
<script type="IN/Login" data-onAuth="loadData"></script>
但它會在網頁加載時自動運行。我想使用網頁上的按鈕或鏈接調用此腳本。這個想法是,網頁加載並等待用戶準備好進行身份驗證。
理想情況下,我希望LinkedIn登錄圖像出現,然後等待,直到點擊。
謝謝。
根據您的評論,看起來您只想顯示SignIn plugin,如果用戶手動點擊了頁面上的按鈕/元素。像這樣的東西,使用jQuery,應該工作:
在您的網頁,你有一個按鈕:
<div id="buttonControl">
<input type="button" id="showLinkedIn" value="Show LinkedIn" onclick="showLinkedIn();" />
</div>
<div id="buttonContent" style="display: none;"></div>
在腳本塊在頁面的<head>
,你有showLinkedIn()
onclick
功能:
function showLinkedIn() {
// insert the SignIn plugin
$('#buttonContent').html('<script type="IN/Login" data-onauth="loadData"><\/script>');
// tell the LinkedIn JavaScript code to re-parse the element containing the SignIn plugin
IN.parse($('#buttonContent')[0]);
// hide button trigger, if needed
$('#buttonControl').hide();
// show the LinkedIn control
$('#buttonContent').show();
}
$('#buttonControl').click(function(){
$('#buttonContent').html('<script type="IN/Login" data-onauth="loadData"></script>');
$('#buttonControl,#buttonContent').toggle();
IN.User.authorize(loadData);
});
作爲略有不同的 'IN.parse($(' #buttonContent ')[0]);'似乎沒有工作...
測試'IN.User.authorize(loadData)',它運作良好!得到它來自:http://developer.linkedin.com/documents/inauth-inevent-and-inui
您需要從以下方法清除Cookies與
IN.User.logout(callbackFunction, callbackScope);
你需要調用從要註銷該按鈕此功能。
示例使用jQuery:
$('#demo') .click(function()
{
IN.User.logout(console.log("logged out..."));
});
當你說,它會自動運行,你的意思是,腳本標籤會自動顯示在頁面加載LinkedIn的登錄按鈕?您想只在用戶點擊另一個按鈕時才顯示上述按鈕嗎? – 2012-08-11 18:57:34
這就是我正在尋找的。謝謝保羅。幫助讚賞。我想把上面的腳本包裝在一個按鈕中,但是這是「類型」的改變,這讓我感到困惑。 – Jeremy 2012-08-12 17:50:01