Get Web Intent Callback from a Window.open call


#1

Hi,
Wonder if anyone can help. See attached code below:

  • If I launch a Web Intent via a normal “a href”, and then tweet I get the callback. Lovely.

  • If, however, I launch a Web Intent via a window.open, say from a button click, I don’t. See code below.

  • I could, trap the button click, and then call click on the “a href”. At this point, I do then get the callback. However, this action in some browsers (e.g. Safari) gets caught in the pop-up blocker, so no-one sees the popup. Which is a bit useless.

I would like to use the window.open approach, and get the callback. Any thoughts anyone?

***** START OF CODE ******

<!doctype html>
<html lang="en">
<head lang=en>
	<meta charset="utf-8">
	<title>Web Intent t3 Experiment</title>
	<script src="http://d3js.org/d3.v3.min.js"></script>
	<script src="https://platform.twitter.com/widgets.js" type="text/javascript"></script>
</head>
<body>

<a href="https://twitter.com/intent/tweet?url=http://www.google.com&text=testing web intents">Option 1: Tweet via Link</a><br />
<button id="tf_sendtweet_button">Option 2: Tweet Via Button and JS</button>
 
<script type="text/javascript">
var t_element = d3.select("#tf_sendtweet_button");
t_element.on("click", function() {
		_text = "Some compelling text to go in a tweet";
		_url = "http://www.google.com/";

		var tweet_url = 'https://twitter.com/intent/tweet?text=';
		tweet_url += encodeURIComponent(_text);
		tweet_url += '&url=' + encodeURIComponent(_url);
		window.open(tweet_url,'_blank');
});



// Here, trap the callback from the WebIntent.
twttr.ready(function (twttr) {
	// bind events here
	twttr.events.bind('tweet', function (event) {
		alert("Yay, tweet callback baby. Gotcha.");
		console.log(new Date(), "Sweett, tweet callback: ", event);
	});
}); 
</script>
</body>
</html>

***** END OF CODE ******


#2

Unfortunately you can’t use the callback events features without letting our javascript control the window opening.


#3

Oh. Poot. Well that settles that one. Quelle domage.
Thanks for answering so quickly though.


#4

#5

#6

#7