【问题标题】:Links opening page *over* current page链接打开页面*超过*当前页面
【发布时间】:2023-04-09 07:46:01
【问题描述】:

我有一个网站(此处为:http://kitandmarcin.us),其中包含指向各种外部页面的链接。到目前为止,一切正常。

但是,当点击一个链接时,地址栏并没有改变,并且对于某些链接,它显然是在当前页面上绘制(我的页面通过目标页面的透明部分显示)。

我在 FF5 和 Chrome 中得到了这种行为。在 Chrome 中调查文档的结构(但不是 FF+firebug)显示 embed 元素从包含 SVG 变为包含目标页面。此行为在早期版本的 Chrome 中不存在,在 FF3 或 4 中也不存在。

我的链接嵌入在 SVG 中的一个转折点是嵌入到页面中。

嵌入svg的xhtml:

<embed type="image/svg+xml" id="svg2" data="wedding_layout.svg" src="wedding_layout.svg"/>

嵌入 xhtml 的 SVG 文档片段:

<foreignObject id="foreignObject4221-Gifts" width="225" height="175" x="689.48" y="375" class="body-box">
    <html:body class="body-body" style="text-align: center;width:100%;">
      <html:div style="text-align: center;border-style:none;width:100%;" class="body-cell"> <html:p>Gifts are not expected, but will be gratefully received</html:p><html:p>We have registered with <html:a href="http://www.williams-sonoma.com/registry/2812940/registry-list.html">Williams-Sonoma</html:a> and <html:a href="http://www.jonathanadler.com/giftregs.php?eventid=1421">Jonathan Adler</html:a></html:p>
      </html:div>
    </html:body>
</foreignObject>

有什么方法可以在不使用 javascript 的情况下阻止这种情况?例如,我能否以某种方式在a 标签上使用目标属性?

如果 javascript 是唯一的方法,有什么我应该知道的吗?

更新:快速测试表明 Windows 上的 FF5 和 Chrome 尊重 target="_top" 属性,并按预期加载链接(如果已设置)。

更新 2:这似乎也适用于 Mac 上的 FF5。

【问题讨论】:

  • 这是我见过的最奇怪的网站结构...我不知道您可以在 SVG 文件中嵌入功能网页。
  • 另外,您是否知道您的整个页面会随窗口高度缩放?如果窗口不是全屏,它在我的机器上是不可读的......
  • @Hughes:这是预期的行为。

标签: html firefox google-chrome xhtml svg


【解决方案1】:

您可以在嵌入的 html 锚点上使用 target="_parent" 或 target="_top" 来导航到当前页面中的链接。这消除了您遇到的意外行为。

【讨论】:

    【解决方案2】:

    您可以使用将在另一个浏览器窗口中打开的 target = "_blank"...

    【讨论】:

      猜你喜欢
      • 2015-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-14
      • 2011-01-14
      • 2014-02-23
      相关资源
      最近更新 更多