0

以下 javascript 旨在打开一个新窗口跳转到指定的锚点,在 IE 中运行良好。不幸的是,在 Firefox 中,它会打开窗口,但不会跳转到锚点。

我已经在这个问题上苦苦挣扎了几天(搜索和修改),但无济于事。

如果有人对我如何使其在 IEMozilla 浏览器中按预期工作有任何见解,我将永远感激不尽。

这是包含 window.open() 的 javascript 函数和调用包含 window.open() 的函数的链接:

<html>
<head>
<script language=javascript>
function openPopupWindow_Why(sPopupUrl, sPopupLabel)
{
    window.open(sPopupUrl, sPopupLabel, 'toolbar=no,resizable=yes,
         scrollbars=yes,height=250,width=450', false);
    return false;
}
 </script>
</head>
<body>
<A onclick="openPopupWindow_Why('MyProfile_WhyAsk.htm#ethnicity', 'Why')"
     href="javascript:void(0)" class="WhyAsk">Why do we ask?</a>
</body>
</html>

这是 window.open() 打开的页面上的 HTML 锚点:

<tr>
  <td align="center">
    <a name="#ethnicity">&nbsp;</a>
  </td>
</tr>
4

1 回答 1

1

尝试从种族锚名称中删除 # ,如下所示:

<tr>
  <td align="center">
    <a name="ethnicity">&nbsp;</a>
  </td>
</tr>

至少适用于 IE、Firefox 和 Chrome

于 2009-10-09T22:08:17.997 回答