javascript - hide url at status bar - Stack Overflow

I've read that people have asked this question many times and I have found an answer for it, altho

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.

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

Can anyone please help me with this? Thanks in advance

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.

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

Can anyone please help me with this? Thanks in advance

Share Improve this question edited Dec 31, 2014 at 4:30 Raptor 54.3k47 gold badges248 silver badges399 bronze badges asked Dec 31, 2014 at 4:27 Jaz AbJaz Ab 31 gold badge1 silver badge2 bronze badges 2
  • Please check this link. Might be it helps you. stackoverflow./questions/19256453/… – Lakhan Commented Dec 31, 2014 at 6:20
  • Also try it "window.location.href" in place of "location.href". – Lakhan Commented Dec 31, 2014 at 6:23
Add a ment  | 

2 Answers 2

Reset to default 4

In general, not having a href link in the is not remended for SEO reasons. 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. For your site to rank better in the search results, you will need to href to supply the tree structure for GoogleBot.

To prevent copying I suggest you use a little of jQuery to hide the href tags. It utilises javascript to remove the href tags. On click of the links, it will open a new window with the href location.

Example is provided below:

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="http://code.jquery./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.">Some Link</a>
</body>
</html>

I'm not sure what exactly you get from data:post.href! just try to use return false after url like below :

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744341046a4569402.html

相关推荐

  • javascript - hide url at status bar - Stack Overflow

    I've read that people have asked this question many times and I have found an answer for it, altho

    7天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信