我有一个子窗口,其中包含Twitter共享页面...如何检测Twitter共享表单是否已提交给Twitter?注意:这是一个儿童窗口..
因为我希望在共享窗口关闭后显示一个警告框
twitter sharing submit detection
var myWindow;
function openTwitterWindow(url){
var width=550;var height=425;var left=parseInt((screen.availWidth/2)-(width/2));
var top=parseInt((screen.availHeight/2)-(height/2));
var windowFeatures="width="+width+",height="+height+",status,resizable,left="+left+",top="+top+"screenX="+left+",screenY="+top;
myWindow=window.open(url,"subWind",windowFeatures);
jQuery('form#update-form').submit(function(){
onWindowClose(myWindow, myCallback);
});
}
function myCallback() {
alert("Your message has been shared. Thank you");
}
function onWindowClose(windowRef,callback, period) {
period = period || 20;
setTimeout(function check() {
if(windowRef == null || windowRef.closed) {
callback();
} else {
setTimeout(check, period);
}
}, period);
}
上面的代码错了......我需要帮助
<a style="cursor: pointer" onclick="openTwitterWindow('https://twitter.com/share?url=<?php echo $url; ?>&text= and so on and so forth...
答案 0 :(得分:0)
您可以尝试这样的事情:
var child = window.open('urlofchild');
var closetime = setInterval(checkChildClose, 500);
function checkChildClose() {
if (child.closed) {
alert("Child window closed");
clearInterval(closetime);
}
}
答案 1 :(得分:0)
通常,当我设计'子'窗口时,我使用CSS并执行虚拟窗口。然后,您将获得页面中所需的所有信息。然后,您可以使用AJAX和JSON来处理数据。