<a href="javascript:void(0)" onclick="openWin(3,this)">php自学网</a>
这里的javascript:void(0) 是什么意思啊,请高手指教。拜谢。

解决方案 »

  1.   

    JavaScript中void是一个操作符,该操作符指定要计算一个表达式但是不返回值。
      

  2.   

    你可以参考
    http://www.w3school.com.cn/js/pro_js_operators_unary.asp教程
      

  3.   

    代码含义孟子以说这么写是 相当于替换页面#锚点大致等同于
    <a href="#“> 或<a href="javascript:;">区别是空锚点会引起页面返回顶部,而javascript; javascript:void(0),不会引起页面返回顶部 
      

  4.   

    表示一个死链接,点击后没任何效果。
    为了是消除点击事件后的 A 标签默认的跳转事件
    也可以使用<a href="#" onclick="openWin(3,this);return false;">XXXXX</a>代替
    以上方式通过事件中的 return false;来阻止元素默认事件的执行,我觉得从可用性和可读性上比<a href="javascript:void(0)" onclick="openWin(3,this)">php自学网</a>好
      

  5.   

    <a href="javascript:void(0)">该连接无任何操作,和普通文本效果一样。只会显示一个鼠标手型样式
    如果换成#号,在本地文件夹中打开后点击链接,会打开当前文件夹。在应用服务器中http方式打开的
    会是当前页面,有些浏览器会连接到当前页面,相当于刷新一次。有些则无然后操作
    <a href="javascript:void(0)">
    <a href="javascript:return fasle;">效果类似
      

  6.   

    void 运算符对任何值都返回 undefined,通常用来阻止浏览器默认行为。
      

  7.   

    一般都是用作 实现 如下功能,当点击一个超链接的时候,不想出发超链接自带的动作,而触发自定义的js方法,一般与onclick 一起出现。如果不写void(0)点击超链接时候虽然调用js方法,但是也会出现一个弹出页面。
      

  8.   


    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
      

  9.   

    javascript:void(0);表示告诉它(<a>)执行js代码!