简体   繁体   English

当鼠标悬停链接时,隐藏href网址中的状态栏值

[英]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) . 我想从状态替换显示的链接值,并将其设置为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: 您可以通过调用javascript函数而不是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 您可以使用window.status=''设置状态,但是出于安全原因,大多数浏览器默认会阻止更改状态行的尝试

<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. 并且还有许多其他方法可以执行此操作,您可以创建一个jquery函数并将URL放在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;
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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