在html中看到这样的属性:<a href=“#”>搜了好久,感觉不甚明白,现记之,等遇到了再做补充。

# is called an anchor (or hash...). so the link is pointing to an anchor or ID on a page, or it would be if the # had some text after it. As it stands it goes nowhere because it doesn't have text after it.

In case you are wondering WHY a link would go nowhere, they are probably using "#" as a placeholder. An anchor tag would not behave as an anchor tag w/o the HREF, but setting an actual HREF might send you off the page each time you are testing. That is annoying, so "href='#'" works out nicely.

Addition tips. you can actually use # to jump to a specific part of ANOTHER page. for example let say somewhere in you "about.html" page you have an element with an ID= "theresMore". From any OTHER PAGE, you can link directly to that part of the page with "href=about.html#theresMore" ( do note that would be a relative url just for the example)

下面原文地址:http://blog.sina.com.cn/s/blog_3f8687af01000867.html

使用javascript的时候,通常我们会通过类似:
<a href="#" onclick="javascript:方法">提交</a>
的方式,通过一个伪链接来调用javascript方法.这种方法有一个问题是:虽然点击该链接的时候不会跳转页面.但是滚动条会往上滚,解决的办法是返回一个false.

如下所示:
<a href="#" onclick="javascript:方法;return false;">提交</a>

a href=#与 a href=javascript:void(0) 的区别
#包含了一个位置信息
默认的锚点是#top 也就是网页的上端而javascript:void(0)  仅仅表示一个死链接这就是为什么有的时候页面很长,浏览链接明明是#可是跳动到了页首
而javascript:void(0) 则不是如此,所以调用脚本的时候最好用void(0)或者<input onclick><div onclick>等

打开新窗口链接的几种办法
1.window.open('url')
2.用自定义函数
        <script>
        function openWin(tag,obj)
        {
            obj.target="_blank";
            obj.href = "Web/Substation/Substation.aspx?stationno="+tag;
            obj.click();
        }
        </script>
<a  href="javascript:void(0)" onclick="openWin(3,this)">杭州</a>
(注:该方法可以解决超级链接的onclick事件经过判断再设置href达到分类重定向的效果)

上一篇:FineUIMvc v1.4.0 发布了(ASP.NET MVC控件库)!


下一篇:Android Drawable Mipmap Vector使用及Vector兼容