开发者

How to make an anchor tag not go to a URL/Open a file

I basically have a webpage with two frames.

-Left for nav
-Right for main content. I have a text-box here called "file_path"

Currently, I have a list of files on the left开发者_JAVA技巧 hand side that I am displaying as anchors. I want the functionality that if the user clicks a file on the left hand frame, I can grab the value and put it in the text-box on the right hand frame. I able to do this successfully, but the problem is that after getting the value in the right frame, my left-frame opens the file in that section ... I want to prevent the file from being open. I only want it to pass the value there.

echo "<li><a href=\".$filepath.\" onClick=\"parent.right.document.getElementById('file_path').value='$filepath'\">$filepath</a></li>";

I tried merely putting the onClick for the list item, but this way I loose functionality, so that the user feels that the link is clickable. It just appears as static text ... I'd rather have the cursor change when the user goes on it like an anchor tag, but just not open the file ... Is this possible?

echo "<li onClick=\"parent.right.document.getElementById('file_path').value='$filepath'\">$filepath</li>";


<a href="nothing.html" onclick="return false;">Clicking me does nothing</a>

Returning false from the onclick - whether it is from a function's return value or put straight in there - will disable the default behaviour of the anchor.


You need to set the href attribute of the links to be href = 'javascript:void(0);'. They'll be links, but won't go anywhere.

G


just put <a style="cursor:pointer" onclick="...">bla bla bla</a>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜