2012-11-06 35 views
2

我希望能夠在我的所有網站頁面上擁有stumbleupon按鈕,但始終讓它「絆倒」我的主頁。我怎樣才能將這個功能添加到按鈕?使用單個URL創建一個Stumbleupon按鈕

這裏是StumbleUpon公司給我:

< - 將這個標籤您希望蘇徽章的位置 - >

< su:badge layout="5" ></su:badge> 

< - 將這個片段在適當情況下! - >

< script type="text/javascript"><br> 
    (function() { 
    var li = document.createElement('script'); li.type = 'text/javascript'; li.async = true; 
    li.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + '//platform.stumbleupon.com/1/widgets.js'; 
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(li, s); 
    })(); 
< /script> 

這裏是我的地盤fairivy.com

謝謝!

回答

1

您可能需要自定義JS腳本是stumblupon提供,嘗試改變在JS這條線,並將其託管在自己的網站:

if(this.type=='follow') 
return scheme+'www.'+ this.domain+ followBase+'?id='+ this.ref+'&l='+ this.layout;else if(this.type=='bestof') 
return scheme+'www.'+ this.domain+ bestofBase+'?'+ this.request.join('&')+'&l='+ this.layout+'&title='+ encodeURIComponent(this.title); 

如果您使用此解決方案,您可能必須進行一個獨立的.js只有你的主域名。

,你還需要這條線更改爲您的自定義位置:在您想要的標誌,讓

'//platform.stumbleupon.com/1/widgets.js' 
+0

哪一段代碼會更改爲新代碼? – user1803660

+0

複製整個javascript文件,替換「this.domain + followBase +'?id ='」和「this.domain + bestofBase +'?'」,簡單地說:「fairivy.com」 – Ariosa

+0

對不起,很厚,但我不是甚至有點程序員。我試過你提到的,但按鈕消失了。我認爲我沒有正確輸入:( – user1803660

2

,編輯從本代碼:

<su:badge layout="5"></su:badge> 

要這樣:

<su:badge layout="5" location="http://www.fairivy.com/"></su:badge> 
+0

這是正確的答案,它應該被標記爲如此。 – endyourif