<a href="javascript:void(0)" onclick="openWin(3,this)">php自学网</a>
这里的javascript:void(0) 是什么意思啊,请高手指教。拜谢。
这里的javascript:void(0) 是什么意思啊,请高手指教。拜谢。
解决方案 »
- js中的var a = new A;与var a = new A();有什么区别?
- 日历控件(四)
- 用jquery ajax动态添加进来的DIV无法获取效果
- 大家帮看下哪里不符合标准?
- 當輸入qq密碼的時候我能得到密碼嗎?
- 小女刚学js.迷茫中。。。求大牛赐教。。。题目越长越好,越长越好,越长越好,越长越好,越长越好,越长越好,越长越好,越长越好,越长越好,越长越好,越长越好。。。
- 图片部分区域触发如何实现
- 请教如何触发html中option组件的事件
- JQ绑定click事件在IE下失效
- js 遍历 json数据的方法?
- alert()添加之后的效果
- js产生两组随机数,第一组产生不重复随机数组,第二组产生不包括第一组数据的不重复随机数
http://www.w3school.com.cn/js/pro_js_operators_unary.asp教程
<a href="#“> 或<a href="javascript:;">区别是空锚点会引起页面返回顶部,而javascript; javascript:void(0),不会引起页面返回顶部
为了是消除点击事件后的 A 标签默认的跳转事件
也可以使用<a href="#" onclick="openWin(3,this);return false;">XXXXX</a>代替
以上方式通过事件中的 return false;来阻止元素默认事件的执行,我觉得从可用性和可读性上比<a href="javascript:void(0)" onclick="openWin(3,this)">php自学网</a>好
如果换成#号,在本地文件夹中打开后点击链接,会打开当前文件夹。在应用服务器中http方式打开的
会是当前页面,有些浏览器会连接到当前页面,相当于刷新一次。有些则无然后操作
<a href="javascript:void(0)">
<a href="javascript:return fasle;">效果类似
void
The void operator returns undefined for any value. This is typically used to avoid outputting a value
that shouldn’t be output, such as when calling a JavaScript function from an HTML <a> element. To do
this properly, the function cannot return a valid value; otherwise the browser erases the page and displays
only the result of the function. For example:
<a href=”javascript:window.open(‘about:blank’)”>Click Me</a>
If you place this line of code into an HTML page, and click the link, you see “[Object]” printed on the
screen (Figure 2-3). This occurs because window.open() returns a reference to the newly opened window
(this and other methods of the window are discussed further in Chapter 5, “JavaScript in the
Browser”). That object is then converted to a string for display.
To avoid this, use the window.open() call with the void operator:
<a href=”javascript:void(window.open(‘about:blank’))”>Click Me</a>
This makes the window.open() call return undefined, which is not a valid value and is not displayed
in the browser window. Remember, functions that have no return value actually return undefined.说下,主要是说如果href属性有返回值,brower就会erase 当前页面,并显示返回值
,可以用返回值undefined来阻止这种默认行为,
void(window.open)返回undefined