pass a javascript variable from an iframe to the parent frame

后端 未结 2 1823
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-20 17:31

So I have a variable in my iframe like so:

 

Now I want to pass that

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-20 18:30

    If the pages are both on the same domain, you could call a function of the parent window:

    window.parent.zipPhoneCallback(zipphone);
    

    In the parent window, you could define a function like this:

    function zipPhoneCallback(zipphone) {
        ((console&&console.log)||alert)("zipphone = " + zipphone);
    }
    

提交回复
热议问题