简体   繁体   中英

JavaScript getting the URL in browser from an iframe

I am using a free site. that free site has a free app. In that free app I can run PHP code from my server.

What JavaScript code can get me the URL of the address showing in browser called from an iframe on my server?

Thanks -Ed

If I understand you right, you want to get the URL of the main window from the iframe. If so (from the page in the iframe):

window.parent.location.href

NB: Security policies on browsers will not allow you to access the this property if the main window and the iframe are accessed on different domains.

var addressBarURL = top.location.href;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM