Hide status bar value from href url when mouse hov

2020-03-26 11:49发布

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?

4条回答
祖国的老花朵
2楼-- · 2020-03-26 12:09

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>
查看更多
Summer. ? 凉城
3楼-- · 2020-03-26 12:18

Try this:

<a href="javascript:void(0)" onclick="location.href='" . $ajax_like_link . "'">Link</a>
查看更多
Fickle 薄情
4楼-- · 2020-03-26 12:21

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>
查看更多
Ridiculous、
5楼-- · 2020-03-26 12:28

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. e.g

<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;
});
查看更多
登录 后发表回答