开发者

function not working properly in chrome

Hi I have开发者_如何学运维 a function that's working correcty in Firefox, but failing in chrome. It's supposed to open a test window, and IF successful, close the test and redirect the parent. I'm still getting into java. I understand there are differences in how browsers interpret JS, just not sure why in this instance, chrome is redirecting the parent window even if the child "testWindow" is not created (e.g.). I'd apprecitate your comments

thanks Gillian

<script type="text/javascript">
function openwindow(){
    testWindow =    window.open("popup.php","interaction");
    if(testWindow){ 
        setTimeout(function() { testWindow.close(); },1000);
        setTimeout(function() { window.parent.location = "http://www.google.com"; },1000);
    }
}
</script>


I just tested your javascript in chrome, it opens a window, then close it and redirect you to goole. I think it's worked as intended. Can you be more precise about your problem ?

BTW, I think windo.open returns null if there was an error, so maybe you should change your if condition to (testWindow !== null) to avoid some browser compatibility problems.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜