Ad
How Can I Handle An Event To Open A Window In React Js?
I want to open a window after clicking the fshare:
My render()
return is like this
<Modal.Footer>
<img src="/static/img/fshare.png" onClick={this.fbShare} />
<Button onClick={this.hide}>Close</Button>
</Modal.Footer>
I am creating a function
fbShare: function(event) {
},
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.
Ad
Answer
You are on the right way!
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')
);
Ad
source: stackoverflow.com
Related Questions
- → Import statement and Babel
- → should I choose reactjs+f7 or f7+vue.js?
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → .tsx webpack compile fails: Unexpected token <
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → React Native with visual studio 2015 IDE
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
- → How do I determine if a new ReactJS session and/or Browser session has started?
- → Alt @decorators in React-Native
- → How to dynamically add class to parent div of focused input field?
Ad