2012-10-11 31 views
-1

ShareThis代碼我們正在使用激活彈出窗口基於懸停在電子郵件按鈕(.st_email),但我似乎無法讓彈出窗口使用jQuery自動激活。如何使用jQuery激發ShareThis彈出窗口?

我試過..

$(".st_email").mouseover(); 
$(".st_email").click(); 

任何想法?

這裏是嵌入ShareThis代碼:

<!-- ShareThis Code --> 
<script type="text/javascript">var switchTo5x=true;</script> 
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script> 
<script type="text/javascript">stLight.options({publisher: "########"}); </script> 

回答

0

你的例子假設你有與 st_email的元素(這是在st_email面前意味着什麼)。

那選擇器將選擇該元素,但你必須做東西在事件處理程序:

$(".st_email").mouseover(function(e) { /* Write code to show your popup */ }); 

我不能在評論一塊充滿不知道更多關於你的彈出窗口。

如果你這樣做有鼠標懸停,需要正確處理接收多個鼠標懸停事件的可能性。

使用處理點擊在這方面比較容易,如果您的情況是可以接受的。這裏的代碼演示如何應對單擊事件:

$(".st_email").click(function(e) { alert('put code here to open popup'); }); 
+0

對不起,我沒有說清楚就好了。我的目標是讓現有的ShareThis彈出窗口在頁面加載時自動打開,除此之外不會創建我自己的彈出窗口。 –

+0

發佈您嵌入ShareThis小部件的代碼。 –

1

嘗試這樣

<script type="text/javascript">stLight.options({publisher: "########",onhover: false}); </script>