Javascript 在iframe中更新href

Javascript 在iframe中更新href,javascript,html,iframe,Javascript,Html,Iframe,单击下面的链接时,会弹出一个模式 <a href="">Link</a> 模态的内容来自iframe。现在我在iframe中有一个锚链接,当用户单击该链接时,我想将用户重新定向到一个URL。我尝试了window.top.location.href='www.google.com',但没有成功 我有关闭模式的代码但是如果我做了类似的事情 <a href="www.google.com" onclick="parent.closemodal();">iFr

单击下面的链接时,会弹出一个模式

<a href="">Link</a>

模态的内容来自iframe。现在我在iframe中有一个锚链接,当用户单击该链接时,我想将用户重新定向到一个URL。我尝试了window.top.location.href='www.google.com',但没有成功

我有关闭模式的代码但是如果我做了类似的事情

 <a href="www.google.com" onclick="parent.closemodal();">iFrame
 Link</a>

它不起作用。
任何想法都值得赞赏

www.google.com阻止在iframe中查看他们的主页。小提琴:。(
)根据控制台

<a id="tagID" href="www.google.com" onclick="parent.closemodal();">iFrame Link</a> 
Refused to display 'https://www.google.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.


要更改从iframe内的页面加载的页面的URL,请使用以下命令:

document.location="http://www.example.com"

我想你漏掉了什么?我知道我漏掉了什么,这就是它不起作用的原因:)在开始的时候,问题与所有这些编辑后的问题大不相同。我试过了,但它指向我的目录…比如。实际上,我并没有试图显示谷歌,我正在尝试将用户重新定向到我网站上的某个页面。我不想更改源代码但我想更改页面的URL。像这样,在用户单击iframe链接后,我想将用户重定向到一个页面。@Jay那么我的原始答案有什么问题?
document.location="http://www.example.com"