views:

227

answers:

1

The following javascript, intended to open a new window and jump to a specified anchor, works great in IE. Unfortunately, in Firefox, it opens the window, but it doesn't jump to the anchor.

I've been struggling with this problem for a couple of days now (searches and modifications) to no avail.

If anybody has any insight as to how I can get this to work as intended in both IE and Mozilla browsers, I'd be forever grateful.

Here's the javascript function containing window.open() and the link calling the function containing 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>

Here's the HTML anchor on the page that's opened by window.open():

<tr>
  <td align="center">
    <a name="#ethnicity">&nbsp;</a>
  </td>
</tr>
+1  A: 

Try removing the # from the ethnicity anchor name like so:

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

Works in at least IE, Firefox and Chrome

Gordon Tucker
You fixed it Gordon. Much obliged!
cjo30080