Forum

Yampiz Forum

Sharing let knowledge Spreaded, Reading let spirits growth, Creative let culture extended, Let us
  • 禁止廣告文
  • 知識傳播
  • 閱讀
  • 心靈成長
  • 創作
  • 文化傳承
Forum Dictionary / Programming / 網頁/網站程式 / JavaScript /

javascript:void(0) 有什麼作用

New Subject
Random
Previous
Next
|
javascript:void(0) 有什麼作用

一般我們在使用連結指令寫法:

<a href="...">我是連結</a>

若是我們需要利用這個連結去執行 Javascript 指令又想要保持連結的樣式時,我們就可以使用這個指令:

<a href="javascript:void(0);" onclick="..java指令..">我是連結</a>

但是這樣子的指令寫法會造成 window.location 功能的失效。所以有些人會使用這樣的方法:

<a href="#" onclick="..java指令..">我是連結</a>

但這個方法又會每次移動頁面到網頁頂端,所以魚戀秋波建議以下的用法:

<a href="#" onclick="..java指令..;return false;">我是連結</a>

就是在執行 Javascript 指令之後加上 return false; 讓程序返回失敗 <a>連結自然就不會執行。

  • Keywords : 連結, 指令, onclick, java指令, 方法, 執行, return, false, Javascript, 連結自然就, 連結去執行, 用法, 樣式, 會每, 指令寫法會, 後加上, 失效, 功能, 利用這, 但這
0 0
2009-10-07T12:35:49+0000

學生妹瀨043811 :

!!! The contents has been hidden because it violates policy tactic. !!!
0 0
2019-01-29T16:53:03+0000


  • Now, you can post comments by Facebook Account when your Yampiz account was logout or unvariable. whatever, we suggest to post comment by Yampiz Account to get more bounds to join new events of Heyxu
Comment
 
Verify
  • Auto Platform
    For better browsing experience, it will auto detects your device to display webpage.
  • Bug Report
    Tell us about the idea, problem and errors you found.
  • Comodo Secure
    The sensitive data transmission adopts by SSL-2048 authenticated encryption.
  • Copyright
    © 2009 YamPiz Digital Inc. & Jaby Group. All rights reserved.
  • Revised Version
    V2.2.061
    03 Aug 2023 (GMT+8)