Javascript 将父页面url拉到iframe中的chrome扩展

Javascript 将父页面url拉到iframe中的chrome扩展,javascript,jquery,html,google-chrome,iframe,Javascript,Jquery,Html,Google Chrome,Iframe,我有一些返回当前访问页面url的JavaScript代码。此代码作为href链接运行。当我使用Chrome扩展打开iframe中的页面(可以是不同的域)时,我想让它也这样做。iframe可以正常打开,但url不会填充。我尝试了window.parent.location类型,但无效 javascript:void(window.open('http://www.example.com/..?s=%20' +encodeURIComponent(document.title)+'%20'

我有一些返回当前访问页面url的JavaScript代码。此代码作为
href
链接运行。当我使用Chrome扩展打开iframe中的页面(可以是不同的域)时,我想让它也这样做。iframe可以正常打开,但url不会填充。我尝试了
window.parent.location
类型,但无效

javascript:void(window.open('http://www.example.com/..?s=%20'
    +encodeURIComponent(document.title)+'%20'
    +encodeURIComponent(location.href)+'%20'
    +encodeURIComponent(window.getSelection())))
可能会帮助你可能会帮助你