Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在iFrame外部打开特定链接_Html_Css_Iframe_Html Target - Fatal编程技术网

Html 在iFrame外部打开特定链接

Html 在iFrame外部打开特定链接,html,css,iframe,html-target,Html,Css,Iframe,Html Target,我的网站有一个特定的部分运行在iFrame中。现在在iFrame内部运行的网页中,我为所有链接指定了,它们都在iFrame内部打开(因此,如果我链接到我的主网站主页,它将在iFrame内部打开)。现在,我想要一个特定的链接打开外部的iframe和内部的正常家长网页 我如何强制某个特定链接这样做?尝试了target=“\u blank”,但仍然在iFrame内部打开。将此添加到链接onclick=“window.location=”url.html';“将此添加到链接onclick=“window

我的网站有一个特定的部分运行在iFrame中。现在在iFrame内部运行的网页中,我为所有链接指定了
,它们都在iFrame内部打开(因此,如果我链接到我的主网站主页,它将在iFrame内部打开)。现在,我想要一个特定的链接打开外部的iframe和内部的正常家长网页


我如何强制某个特定链接这样做?尝试了
target=“\u blank”
,但仍然在iFrame内部打开。

将此添加到链接
onclick=“window.location=”url.html';“
将此添加到链接
onclick=“window.location=”url.html'”
我很久以前遇到过这个解决方案,从那时起一直在使用它。使用Javascript函数强制链接:

<script type='text/javascript'>
 function newWindow(){
   top.location.href = 'http://yourURL';};
</script>
<a href="javascript: newWindow();">YourLink</a>

函数newWindow(){
top.location.href=http://yourURL';};

不久前我遇到过这个解决方案,从那时起我就一直在使用它。使用Javascript函数强制链接:

<script type='text/javascript'>
 function newWindow(){
   top.location.href = 'http://yourURL';};
</script>
<a href="javascript: newWindow();">YourLink</a>

函数newWindow(){
top.location.href=http://yourURL';};

如果您使用的是JavaScript:

parent.document.location=”http://www.google.com"
如果您使用的是HTML:


如果您使用的是JavaScript:

parent.document.location=”http://www.google.com"
如果您使用的是HTML:


当我制作菜单时,我会在index.html中制作一个iframe:

<div id="nav">
     <iframe frameBorder="0" height="35px" width="950px" src="navframe.html"></iframe>
</div> 

然后在navframe.html中,以下是我的按钮:

<button type="button" onClick="window.parent.location='index.html'">
Home</button>

<button type="button" onClick="window.parent.location='contact.html'">
Contact</button>

家
接触

当我制作菜单时,我会在index.html中制作一个iframe,这通常会起作用:

<div id="nav">
     <iframe frameBorder="0" height="35px" width="950px" src="navframe.html"></iframe>
</div> 

然后在navframe.html中,以下是我的按钮:

<button type="button" onClick="window.parent.location='index.html'">
Home</button>

<button type="button" onClick="window.parent.location='contact.html'">
Contact</button>

家
接触

这很管用

谢谢你的回答,但它不管用。尝试了设置href='url.html'和不设置href='url.html'…还有其他建议吗?请注意,通常不建议在html中添加内联JavaScript。更好的做法是在加载DOM对象(链接)后,通过脚本附加此单击事件处理程序。谢谢您的回答,但它不起作用。尝试了设置href='url.html'和不设置href='url.html'…还有其他建议吗?请注意,通常不建议在html中添加内联JavaScript。更好的做法是在加载DOM对象(链接)后,通过脚本附加此单击事件处理程序。