c#在浏览器标签的鼠标悬停工具提示上显示不同的文本

时间:2022-08-26 23:49:12

Is it possible to change the text that appears when you hover a tab in a browser. For example:c#在浏览器标签的鼠标悬停工具提示上显示不同的文本

是否可以更改浏览器中悬停标签时出现的文本。例如:

I want the tag text to stay the same but be able to change the grey text that appears when you hover over it.

我希望标签文本保持不变,但是可以改变鼠标悬停时出现的灰色文本。

The reasoning for this as due to having a site on a clustered server. I want the main tab to remain the same to avoid confusing users but to help support issues by showing the server the site is in the hover part.

这是因为集群服务器上有一个站点。我希望主选项卡保持不变,以避免让用户感到困惑,但通过向服务器显示站点在悬浮部分,以帮助支持问题。

I have my server name in a view bag like so:

我把我的服务器名放在这样的视图包中:

 ViewBag.ServerName = System.Environment.MachineName;

Is what I am after feasiable can anyone point me in the correct direction?

我所追求的是可行的吗?有人能给我指出正确的方向吗?

2 个解决方案

#1


1  

The behavior you're looking for unfortunately cannot be achieved (at least in current browsers displaying HTML). The text shown in the hover tooltip is not controlled directly by the document, but by the browser. For example, Chrome (as do all browsers I know of) displays the full contents of the <title> tag when you hover the tab name.

不幸的是,您正在寻找的行为无法实现(至少在当前显示HTML的浏览器中)。鼠标悬停工具提示中显示的文本不是由文档直接控制的,而是由浏览器控制的。例如,当您悬停标签名时,Chrome(和我所知道的所有浏览器一样)显示

标签的全部内容。</p>

I suppose you could hack a solution by changing the title when the document body is out of focus, but at that point you should consider whether there's a better solution for what you're actually trying to do.

我认为您可以通过在文档主体不在焦点时更改标题来破解一个解决方案,但是此时您应该考虑是否有更好的解决方案来解决您实际正在尝试的问题。

If you only need to support Chrome, control the user's computers (e.g. in an enterprise environment) and really really need this behavior, you could create your own Chrome extension which does this (How to alter title of present tab using chrome extension).

如果你只需要支持Chrome,控制用户的电脑(例如在企业环境中),并且真的需要这种行为,你可以创建自己的Chrome扩展来实现这一点(如何使用Chrome扩展来改变present标签的标题)。

#2


0  

I fear besides the title tag you cannot change anything up there, because the browser handles that by itself plus every browser does it differently.

我担心除了标题标签你不能改变上面的任何东西,因为浏览器自己处理它加上每个浏览器做它不同。

#1


1  

The behavior you're looking for unfortunately cannot be achieved (at least in current browsers displaying HTML). The text shown in the hover tooltip is not controlled directly by the document, but by the browser. For example, Chrome (as do all browsers I know of) displays the full contents of the <title> tag when you hover the tab name.

不幸的是,您正在寻找的行为无法实现(至少在当前显示HTML的浏览器中)。鼠标悬停工具提示中显示的文本不是由文档直接控制的,而是由浏览器控制的。例如,当您悬停标签名时,Chrome(和我所知道的所有浏览器一样)显示

标签的全部内容。</p>

I suppose you could hack a solution by changing the title when the document body is out of focus, but at that point you should consider whether there's a better solution for what you're actually trying to do.

我认为您可以通过在文档主体不在焦点时更改标题来破解一个解决方案,但是此时您应该考虑是否有更好的解决方案来解决您实际正在尝试的问题。

If you only need to support Chrome, control the user's computers (e.g. in an enterprise environment) and really really need this behavior, you could create your own Chrome extension which does this (How to alter title of present tab using chrome extension).

如果你只需要支持Chrome,控制用户的电脑(例如在企业环境中),并且真的需要这种行为,你可以创建自己的Chrome扩展来实现这一点(如何使用Chrome扩展来改变present标签的标题)。

#2


0  

I fear besides the title tag you cannot change anything up there, because the browser handles that by itself plus every browser does it differently.

我担心除了标题标签你不能改变上面的任何东西,因为浏览器自己处理它加上每个浏览器做它不同。