href链接到#问题 [英] href link to # question

查看:85
本文介绍了href链接到#问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于href链接的问题,试图用google搜索它,但是在这方面找不到很多信息。我有这样的href链接:

 < a href ='#'onclick ='openSerialWindow(); return false; '>< h:outputText value =#{i18n.regFindSerialNumber}/>< / a> 

之前的已被页面替换.htm它应链接到并导致错误,当用户右键单击该链接并选择在新窗口/选项卡中打开。使用#替换page.htm后,它可以正常工作,甚至可以在r / c中打开它。



如果用户只需双击链接上面的工作(#和page.htm),所以我想知道



感谢。

解决方案

是一个锚点散列并指向您可以在文档中创建锚点,如下所示:< a name ='anchor'>< / b& a> 然后通过将 #anchor 添加到页面的URL来跳转到它们。如果链接到page.htm产生错误,那么 page.htm 是不正确的链接。

href 属性只有在没有Javascript的情况下才会作为回退。 Javascript的返回false; 阻止链接的执行。链接到表示如果关闭javascript,则通过单击链接将不会发生任何事情,除非浏览器将跳转到页面的顶部。


I have a question about the href link, tried googling it but could not find much info on this. I have a href link like this:

<a href='#' onclick='openSerialWindow();return false;'><h:outputText value="#{i18n.regFindSerialNumber}" /></a>

previously the # was replaced by the page.htm that it should link to and that caused an error when user right clicked on the link and chose 'Open in new window/tab'. After replacing the page.htm with # it works fine user can even r/c and open it in new tab/window.

If user simply clicked on the link both ways above worked (the # and page.htm), so I am wondering what is the true meaning of #?

thanks.

解决方案

# is an anchor hash and points to the top of the current page.

You can create anchors in your document like this: <a name='anchor'></a> and then jump to them by adding #anchor to the page's URL. The browser will jump to the position without reloading.

If linking to page.htm produced an error, then page.htm is an incorrect link.

The href attribute is there only as fallback in case there is no Javascript. Javascripts's return false; prevents execution of the link. Linking to # means that if javascript is turned off, nothing will happen by clicking on the link except that the browser will jump to the top of the page.

这篇关于href链接到#问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆