【问题标题】:ASP.NET LinkButton - How to Hide javascript:_doPostBack?ASP.NET LinkBut​​ton - 如何隐藏 javascript_doPostBack?
【发布时间】:2011-05-10 03:09:36
【问题描述】:
<asp:LinkButton ID="cartLink" runat="server" Text="<b>Add to Cart</b>" 
    ToolTip="Add to cart" CommandName="Add" 
        CommandArgument='<%# Eval("ProductID") %>' />

查看源代码:

    <a id="ContentPlaceHolder1_productsList_cartLink_0" 
        title="Add to cart" 
        href="javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$productsList$ctrl0$cartLink&#39;,&#39;&#39;)">
        <b>Add to Cart</b></a>

将鼠标悬停在 LinkBut​​ton 上时,我不会丢失浏览器底部出现的丑陋的“javascript_doPostBack(...)”链接状态消息。

是否可以抑制这个?

2011 年 5 月 11 日更新:

我意识到这是默认行为,大多数时候我几乎没有注意到它。但是,当状态栏不显示(这是默认设置)时,这只是 IE9 中的问题。有人知道解决此问题的有效方法吗?

【问题讨论】:

  • 你在什么浏览器上测试它?我没有看到任何“javascript_do..”作为工具提示。请参阅此jsfiddle.net/upmne。它只是出现在浏览器状态栏区域中,但完全没有侵入性。
  • 目前在 Windows 上的 Firefox 4.0 和 IE9 中进行测试。诚然,它在 Firefox 中的侵入性不是很大。然而在 IE9 中,它看起来很浮雕,周围有一个底部阴影 - 真的很烦人......
  • @Bala,我已经更新了大卫的问题 - 我实际上指的是悬停在链接上时出现的状态消息。

标签: javascript asp.net javascript-events


【解决方案1】:

如果您指的是大多数浏览器窗口左下方显示的 Javascript 状态消息,请尝试设置 onMouseOver 值。

<asp:LinkButton ID="cartLink" onMouseOver="JavaScript:window.status='Yo, I'm the Javascript status text!'; return true" onMouseout="JavaScript:window.status=''; return true" runat="server" Text="<b>Add to Cart</b>" ToolTip="Add to cart" CommandName="Add" CommandArgument='<%# Eval("JOBProductIDName") %>' />  

请参阅this page 了解更多信息。

【讨论】:

  • @Irish。您是否检查过在 Firefox 中启用了状态栏消息?我的答案中链接中的说明。
  • Firefox 4 中的设置与链接文章中的不同。此外,我需要让它适用于默认浏览器设置,在这个阶段我更关心 IE9(周围有阴影);见我上面对巴拉的评论:)
  • 我用 onMouseOver="window.status=..." 试过了,还是不行?
猜你喜欢
  • 2017-09-22
  • 1970-01-01
  • 1970-01-01
  • 2023-03-28
  • 2011-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多