我该如何处理在React JS中打开窗口的事件? [英] how can i handle an event to open a window in react js?

查看:127
本文介绍了我该如何处理在React JS中打开窗口的事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单击fshare后打开一个窗口

I want to open a window after clicking the fshare

我的render()回报是这样

<Modal.Footer>
    <img src="/static/img/fshare.png" onClick={this.fbShare} />
    <Button onClick={this.hide}>Close</Button>
</Modal.Footer>

我正在创建一个函数

fbShare: function(event) {

},

我想在该函数内添加以下代码,该函数基本上会打开一个新窗口以在Facebook中共享:

And I want to add the following code inside the function that basically opens a new window to share in Facebook:

window.open('https://www.facebook.com/dialog/feed?app_id=xxxxxxxxe='sharer', 'toolbar=0,status=0,width=548,height=325');" target="_parent" href="javascript: void(0)">

但是我对如何处理此事件感到困惑.

But i am confused with how to handle this event.

任何建议将不胜感激. 预先感谢

Any suggestion will be highly appreciated. Thanks in advance

推荐答案

您的方法正确!

这是您需要的东西吗?我准备了示例: 点击此处

Is it something you need? I prepared the example: click here

var Example = React.createClass({
    fbShare: function() {
        window.open('http://www.facebook.com/sharer.php?s=100&p[title]=Fb Share&p[summary]=Facebook share popup&p[url]=javascript:fbShare("http://jsfiddle.net/stichoza/EYxTJ/")&p[images][0]="http://goo.gl/dS52U"', 'sharer', 'toolbar=0,status=0,width=548,height=325');
    },

    render: function() {
        return (<div>
            <img src="http://pasadenainstitute.com/fb-shareTransp122x42.png" onClick={this.fbShare} />
        </div>);
    }
});

ReactDOM.render(
    <Example />,
    document.getElementById('container')
);

这篇关于我该如何处理在React JS中打开窗口的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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