简体   繁体   中英

Hide status bar value from href url when mouse hover a link

This is the link that I have:

href='" . $ajax_like_link . "' data-task='like' data-post_id='" . $post_id . "' data-nonce='" . $nonce . "'>";

And I want to replace the displayed link value from status and set to javascript:void(0) .

How can I accomplish this?

尝试这个:

<a href="javascript:void(0)" onclick="location.href='" . $ajax_like_link . "'">Link</a>

you can do it by calling javascript function instead of link in href:

   <a href='javascript:void(0)' onclick='gotoLink(\"". $ajax_like_link ."\")' .......>link</a>
    <script>
    function gotoLink(url) {
        window.location = url;
    }
    </script>

You can set the status with window.status='' but most browsers will block attempts to change the status line by default for security reasons

<a href="link" onmouseover="window.status='javascript:void(0)';" onmouseout="window.status='';">link here</a>

So a better way is to

<a href="javascript:void(0)" onclick="location.href='" . $ajax_like_link . "'">Link</a>

a more shorter syntax of doing this is

<a href="javascript:;" onclick="location.href='" . $ajax_like_link . "'">Link</a>

and there are many other ways of doing this, you can create a jquery function and just put the url in the attibute. eg

<a href="javascript:;" rel='" . $ajax_like_link . "'" class="goto">Link</a>

$(".goto").click(function() {
    var gotolink = $(this).attr('rel')
    if(gotolink!=undefined || gotolink!='')
         location.href = gotolink;
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM