get first parent of iframe javascript

Posted by baaroz on Stack Overflow See other posts from Stack Overflow or by baaroz
Published on 2012-10-30T10:58:47Z Indexed on 2012/10/30 11:01 UTC
Read the original article Hit count: 133

Filed under:

I have a iframe inside test.aspx,when the user click on a pay button inside the Iframe,the iframe redirct to check.aspx that has same iframe

if payment was success on first time, then window.parent.location.href==test.aspx

if payment was failed the iframe redirect again to check.aspx,so now the

window.parent.location.href==check.aspx

while the payement was failed the the iframe keep redirect to check.aspx and the parent location keep changing ,so for example if the client failed 3 time,inside check.aspx I need to do window.parent.parent.parent.location.href to get test.aspx redirect.

when the user payment was success ,then I want to redirect the test.aspx but I can't know how much child iframe window he has!

I need something like

window.parent[0].location.href=success.aspx,so I will be able to redirect the first father window.

Thanks for any Help

Baaroz

© Stack Overflow or respective owner

Related posts about JavaScript