简体   繁体   English

在状态栏隐藏网址

[英]hide url at status bar

I've read that people have asked this question many times and I have found an answer for it, although I had to do it manually for ALL links in my blog. 我已经读到人们多次问这个问题,并且找到了答案,尽管我必须手动处理博客中的所有链接。 But I'm stumbled with the format that I can't get to work: 但是我迷失了无法使用的格式:

the format I use: 我使用的格式:

<a onclick='location.href="#"' style='cursor: pointer;'target='_blank'>

but I can't get it to work for data:post.href, it won't open at all. 但我无法将其用于data:post.href,它根本无法打开。

<a onclick='location.href="data:post.href"' style='cursor: pointer;' target='_blank'>

Can anyone please help me with this? 谁能帮我这个忙吗? Thanks in advance 提前致谢

In general, not having a href link in the is not recommended for SEO reasons. 通常,出于SEO原因,建议不要在中没有href链接。 Google's crawler relies on the the href in the links to crawl the site, and link juice passes on using the href in the tag. Google的抓取工具依靠链接中的href来抓取网站,而链接汁使用标记中的href传递。 For your site to rank better in the search results, you will need to href to supply the tree structure for GoogleBot. 为了使您的网站在搜索结果中排名更高,您需要href来提供GoogleBot的树形结构。

To prevent copying I suggest you use a little of jQuery to hide the href tags. 为了防止复制,我建议您使用一些jQuery来隐藏href标记。 It utilises javascript to remove the href tags. 它利用javascript删除href标记。 On click of the links, it will open a new window with the href location. 单击链接后,它将打开一个具有href位置的新窗口。

Example is provided below: 下面提供了示例:

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
    <script>
        $(function(){
            $("a.hidelink").each(function (index, element){
                var href = $(this).attr("href");
                $(this).attr("hiddenhref", href);
                $(this).removeAttr("href");
            });
            $("a.hidelink").click(function(){
                url = $(this).attr("hiddenhref");
                window.open(url, '_blank');
            })
        });
    </script>
    <style>
        a.hidelink {
            cursor: pointer;
            text-decoration: underline;
        }
    </style>
</head>
<body>
<a class="hidelink" href="http://www.google.com">Some Link</a>
</body>
</html>

I'm not sure what exactly you get from data:post.href! 我不确定从data:post.href到底能得到什么! just try to use return false after url like below : 只需尝试在URL之后使用return false ,如下所示:

<a onclick='location.href="data:post.href";return false;' style='cursor: pointer;' target='_blank'>

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

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