Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何检测子窗口是否已使用javascript提交?_Php_Javascript - Fatal编程技术网

Php 如何检测子窗口是否已使用javascript提交?

Php 如何检测子窗口是否已使用javascript提交?,php,javascript,Php,Javascript,我有一个子窗口,其中包含twitter共享页面。。。如何检测twitter共享表单是否已提交到twitter?注意:这是一个子窗口 因为我想在共享窗口关闭后显示一个警报框 twitter共享提交检测 var myWindow; function openTwitterWindow(url){ var width=550;var height=425;var left=parseInt((screen.availWidth/2)-(width/2)); var top=pa

我有一个子窗口,其中包含twitter共享页面。。。如何检测twitter共享表单是否已提交到twitter?注意:这是一个子窗口

因为我想在共享窗口关闭后显示一个警报框
twitter共享提交检测

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...

您可以尝试以下方法:

var child = window.open('urlofchild');
var closetime = setInterval(checkChildClose, 500);

function checkChildClose() {
    if (child.closed) {
        alert("Child window closed");   
        clearInterval(closetime);
    }
}

通常,当我设计“子”窗口时,我使用CSS和虚拟窗口。然后,您就可以在一个页面中获得所需的所有信息。然后,可以使用AJAX和JSON处理数据


演示:

检测twitter共享表单是否已提交到twitter
无法确定此处的最佳解决方案是什么。。。因为当我点击x按钮关闭窗口时,它会弹出我的警报框,我唯一能想到的避免这种情况的方法是检测twitter共享的提交,然后才会弹出警报,请显示一些代码。我认为无法检测其他页面上的表单是否已提交。请通过
ajax
进行提交,并将您的代码放入
success
twitter is twitter中。我该如何将该内容放入ajax中。twitter提供了只运行一次的共享URL,你不需要安排重新运行吗?如果用户关闭了子窗口,甚至没有点击提交按钮将帖子分享到twitter上,你会怎么做?@sasori没有办法找到答案,除非twitter为此提供了API。查阅“同一原产地政策”,如果没有办法找到,有没有解决这个问题的办法。。。因为如果我要在子窗口关闭时弹出一个警报框,甚至没有提交twitter共享内容,它看起来不正确,但是你仍然有检测跨域iframe中发生了什么的问题。虚拟窗口在这里帮不了你。