如何隐藏浏览器中的状态栏?

发布于 2024-10-05 08:46:50 字数 298 浏览 8 评论 0原文

我有一个简单的问题,如何隐藏浏览器状态栏中的链接。

我尝试过这个:(

<a href="http://www.sell.com/?referrer=225"
   onMouseOver="window.status='http://www.sell.com';
               return true" onMouseOut="window.status=''">Click here</a>

取自教程) 但这不起作用,如果有人能帮助我,我会很高兴! ;-)

I have a simple question, how can I hide a link in the status bar in my browser.

I've tried with this:

<a href="http://www.sell.com/?referrer=225"
   onMouseOver="window.status='http://www.sell.com';
               return true" onMouseOut="window.status=''">Click here</a>

(Taken from a tutorial)
But it doesn't work, if somebody would help me, I would be very happy! ;-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

厌倦 2024-10-12 08:46:50

你不能(至少在当前的浏览器中),这是一件好事。伪装链接对网络钓鱼攻击有很大帮助。

You can't (at least in current browsers), which is a good thing. It would help phishing attacks a great deal to disguise the link.

渔村楼浪 2024-10-12 08:46:50

下面是一些代码,可以在浏览器状态栏区域中隐藏原始链接的文字

请注意:不确定它适用于哪些浏览器,但在 IE9 中运行良好

<a href="javascript:void(0);" onclick="location.href='http://www.google.com';return false;">If You Put Your Mouse Over This Text You Won't See Link In Status Bar Area</a>

当您将鼠标悬停在链接上时,您在状态栏中看到的只是javascript:void(0);

Here is some code that will hide your original link tread text in a browsers status bar area

Please note: not sure which browsers it works on but works fine in IE9

<a href="javascript:void(0);" onclick="location.href='http://www.google.com';return false;">If You Put Your Mouse Over This Text You Won't See Link In Status Bar Area</a>

When you run your mouse over the link, all you see in the status bar is javascript:void(0);

花开雨落又逢春i 2024-10-12 08:46:50

由于您要求这样做是为了隐藏附属链接,因此可能有更好的方法。

更有意义的是循环遍历所有链接,例如在广泛的 $("a.out") 选择器下,然后获取并将其真实的 href 存储到元素存储中,用虚拟的替换它一个(如果需要的话还有标题属性)。

然后,您附加一个单击事件处理程序,该处理程序会停止默认事件,读回原始 href 并将其设置为 location.href,从而有效地伪装所有启用了 js 的链接。

例如 mootools 中的代码:

(function() {
    var links = document.getElements("a.out");

    links.each(function(el) {
        // save original
        el.store("href", el.get("href"));
        // replace it.
        el.set("href", el.get("data-link"));

        el.addEvents({
            click: function(e) {
                e.stop();
                // console.log(e);

                document.location.href = this.retrieve("href");
            },
            contextmenu: function(e) {
                e.stop();
                // do something on right click so we dont get caught
                alert("hi");
            }
        });
    });
})();

在此标记上效果很好:

<a href="http://www.energyhelpline.com/energy/rg_home.aspx?aid=107" rel="nofollow" class="out" title="Enegry savings" data-link="http://www.energyhelpline.com/">Swap Energy Provider</a><br />

<a href="http://www.moneysupermarket.com/link.asp?Source=MSE&Section=utils" rel="nofollow" class="out" title="Money supermarket" data-link="http://www.moneysupermarket.com/">Money Supermarket</a>

使用包含我们向最终用户显示的内容的数据链接。

Since you are asking to do this in order to hide affiliation links, there may be a better way.

It makes far more sense to loop through all your links, say, under a broad $("a.out") selector, then get and store their real href into element storage, replace it with a dummy one (and the title attribute if you have to).

You then attach a click event handler that stops the default event, reads back the original href and sets it as the location.href, effectively disguising the links to all that have js enabled.

Eg code in mootools:

(function() {
    var links = document.getElements("a.out");

    links.each(function(el) {
        // save original
        el.store("href", el.get("href"));
        // replace it.
        el.set("href", el.get("data-link"));

        el.addEvents({
            click: function(e) {
                e.stop();
                // console.log(e);

                document.location.href = this.retrieve("href");
            },
            contextmenu: function(e) {
                e.stop();
                // do something on right click so we dont get caught
                alert("hi");
            }
        });
    });
})();

Which works fine on this markup:

<a href="http://www.energyhelpline.com/energy/rg_home.aspx?aid=107" rel="nofollow" class="out" title="Enegry savings" data-link="http://www.energyhelpline.com/">Swap Energy Provider</a><br />

<a href="http://www.moneysupermarket.com/link.asp?Source=MSE&Section=utils" rel="nofollow" class="out" title="Money supermarket" data-link="http://www.moneysupermarket.com/">Money Supermarket</a>

With data-link containing what we SHOW to end users instead.

呢古 2024-10-12 08:46:50

您可以使用带有 window.status 属性的 javascript 设置状态栏的文本。例如 http://www.htmlite.com/JS017.php

如果您确实需要,请禁用浏览器中的状态栏,您可以获取开源浏览器代码库的副本,删除状态栏的所有代码并将其重新分发给您的用户,但我怀疑这就是您的意思/需要。

为什么需要隐藏状态栏中的链接?不想公开 URL 的安全问题可以通过其他方式处理。

You can set the text of the status bar using javascript with window.status attribute. E.g. http://www.htmlite.com/JS017.php

If you REALLY need, to disable the status bar in a browser, you can get a copy of an open-source browser code base, remove all code for the status bar and redistribute it to your users, but I doubt this is what you mean/need.

Why do you need to hide the link in the status bar? A security issue with not wanting to expose the URL could be dealt with in another way.

镜花水月 2024-10-12 08:46:50

您可以通过在链接中使用 javascript 来做到这一点:

这是如何

function goToBing() {
  window.location.href = "http://bing.com";
}

正如

<a href="http://google.com" onclick="goToBing();return false;">Link to Google</a>

Nick Craver 所说,这并非在所有情况下都有效(按住 Control 键单击、中键单击等),但应该对您有用,因为您不中继 javascript 链接。

You can do this by using javascript for your link:

Here's how:

function goToBing() {
  window.location.href = "http://bing.com";
}

and

<a href="http://google.com" onclick="goToBing();return false;">Link to Google</a>

As Nick Craver said, this doesn't work in all circumstances (control-click, middle-click etc.) but should work for you, because you don't relay on the javascript link.

So尛奶瓶 2024-10-12 08:46:50

这是一种使用 javascript + jQuery 的方法,可以与 ctrl 单击、shift 单击、中键单击等一起使用。它确实会破坏右键单击,但如果目标是隐藏链接,我想这没什么大不了的。

不管你用这个做什么,我不承担任何责任,我这样做主要是为了好玩,但它看起来确实很邪恶。

JS:

$(document).ready(function() {
   $('a').each(function() {
       var address = $(this).attr('href');
       var element = $(this).contents().unwrap().wrap('<div/>').parent();
       element.data("hrefAddress", address).addClass("link");

       element.click(function() {               
           var newWindow = window.open(element.data("hrefAddress"), '_blank');
           newWindow.focus();
       });
   });
});​

CSS:

.link {
    color: #00f;
    text-decoration: underline;
    cursor: pointer;
}

.link:hover {
    color: #00a;
}

HTML:

<div>
    <a href="http://www.facebook.com">Facebook</a>
    <a href="http://www.bing.com">Google</a>
    <a href="http://www.yahoo.com">Yahoo</a>
    <a href="http://stackoverflow.com">Stack Overflow</a>
</div>​

JS Fiddle

Here's a way with javascript + jQuery that works with ctrl click, shift click, middle click, etc. It does break right click, but if the goal is to hide the link I guess that's not a big deal.

I take no responsability whatsoever what you do with this though, I did this mostly for fun, but it does look pretty evil.

JS:

$(document).ready(function() {
   $('a').each(function() {
       var address = $(this).attr('href');
       var element = $(this).contents().unwrap().wrap('<div/>').parent();
       element.data("hrefAddress", address).addClass("link");

       element.click(function() {               
           var newWindow = window.open(element.data("hrefAddress"), '_blank');
           newWindow.focus();
       });
   });
});​

CSS:

.link {
    color: #00f;
    text-decoration: underline;
    cursor: pointer;
}

.link:hover {
    color: #00a;
}

HTML:

<div>
    <a href="http://www.facebook.com">Facebook</a>
    <a href="http://www.bing.com">Google</a>
    <a href="http://www.yahoo.com">Yahoo</a>
    <a href="http://stackoverflow.com">Stack Overflow</a>
</div>​

JS Fiddle

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文