我怎样才能完成弹出模式窗口(包括示例)? [英] How could I accomplish a popup modal window (Example included)?

查看:125
本文介绍了我怎样才能完成弹出模式窗口(包括示例)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何使用javascript打开新的浏览器窗口?

例如: http://www.nowness.com/ >点击Twitter

For example: http://www.nowness.com/ > Click "Twitter"

我不是在询问Twitter API,只是一个我要打开的通用窗口。可以使用jQuery。

I'm not asking about the Twitter API, just a generic window that I want to open up. jQuery can be used.

编辑:Modal是错误的术语。我想要一个弹出窗口,而不是模态。

edit: Modal was the wrong term here. I wanted a popup, not a modal.

推荐答案

只需添加链接

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

和javascript

and the 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>

这篇关于我怎样才能完成弹出模式窗口(包括示例)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆