2012-09-22 35 views
0

可能重複:
How to open new browser window using javascript?我怎樣才能完成一個彈出式模態窗口(包含示例)?

例如:http://www.nowness.com/>點擊 「推特」

我不要求有關Twitter的API,只是我想一個通用的窗口開放。 jQuery可以使用。

編輯:莫代爾在這裏是錯誤的術語。我想要一個彈出窗口,而不是一個模式。

+0

你能還使用jQuery UI? –

+0

模態對話框不是通用窗口。你想要什麼? –

+1

彈出窗口不是模態的。模式窗口將阻止與其他窗口的交互,直到您關閉它爲止。 – Ridcully

回答

1

只需添加您的鏈接

<a class="tweetme" 
    href="https://twitter.com/intent/tweet?text=yourtext&url=yoururl"> 
    Tweet Me 
</a> 

和JavaScript

<script type="text/javascript"> 
    $('.tweetme').click(function (event) { 
     var width = 575, 
       height = 400, 
       left = ($(window).width() - width)/2, 
       top = ($(window).height() - height)/2, 
       url = this.href, 
       opts = 'status=1' + 
         ',width=' + width + 
         ',height=' + height + 
         ',top=' + top + 
         ',left=' + left; 

     window.open(url, 'twitte', opts); 

     return false; 
    }); 
</script> 
+0

美麗,謝謝 –

相關問題