In page anchor not working in firefox

半世苍凉 提交于 2019-12-14 02:01:10

问题


I have got my code something like below which repeats to the number of shots varying for every page. My aim is to open a popup and go to that particular shot straight by url like

www.example.com/shot/#12.

For some reason this works fine in IE and chrome but does no in Firefox. In Firefox it gets pointed to something different but does open the popup.

<repeater>
    <div>
        <div>
            <a href="#ShotNumber" name="#12">
            </a>
        </div>
        <div>
            HTML FOR EACH SHOT
        <div>
    <div>
<repeater>

回答1:


ANCHOR

<a name="Anchorname"></a>

for example: normal way

 <div>
   <a href="#ShotNumber">Go to ShotNumber</a> <!-- Link to ShotNumber -->
   <a href="#12">Go to 12</a> <!-- Link to 12-->
 </div>
 <!-- more stuff -->
 <div>
   <a name="ShotNumber"></a> <!-- Anchor name=ShotNumber -->
   HTML FOR ShotNumber
 </div>
 <!-- more stuff -->
 <div>
   <a name="12"></a> <!-- Anchor name=12 -->
   HTML FOR 12
 </div>

Call it like:

example.com/myShot.html#ShotNumber

EDIT: html5: the-indicated-part-of-the-document

If there is an element in the DOM that has an ID exactly equal to decoded fragid, then the first such element in tree order is the indicated part of the document; stop the algorithm here.

If there is an a element in the DOM that has a name attribute whose value is exactly equal to fragid (not decoded fragid), then the first such element in tree order is the indicated part of the document; stop the algorithm here.




回答2:


Try <a name="12">This is item number 12</a>

and then <a href="#12">Go to item number 12</a>.

Also, the anchor id thing is not supported in HTML5, they say. This might be of interest.



来源:https://stackoverflow.com/questions/13163841/in-page-anchor-not-working-in-firefox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!