简体   繁体   English

如何禁用超过按钮时显示的默认URl

[英]how to disable defalut URl showing when overing on button

Please refer below image 请参考下图

在此处输入图片说明

when ever am handovering it shows some URl in window Bottom of IE browser. 进行切换时,它会在IE浏览器的底部窗口中显示一些URl。 but no url supplied for this button. 但没有为此按钮提供网址。

This is the button code 这是按钮代码

<button id="btnCancel"  >Cancel</button>

How can i remove the invalid URL ? 如何删除无效的URL? why it showing in IE browser ? 为什么在IE浏览器中显示?

Thanks, 谢谢,

Siva 湿婆

It's not something you can ask to client Browser so there is not an official method. 您无法向客户端浏览器询问此内容,因此没有官方方法。 Fortunately there are few workarounds. 幸运的是,解决方法很少。

Let's first see how it's usually done with links: 首先让我们看一下通常如何使用链接来完成:

<a id="myLink" href="#" data-href="http://stackoverflow.com">Click me</a>

<script type="text/javascript">
    $(document).ready(function () {
        $("#myLink").click(function (e) {
            e.preventDefault();

            window.location.href = $("#btnCancel").data("href");
            return false;
         });
    });
</script>

Internet Explorer shows same link for submit buttons too when they're in a <form> (and of course target URL is combination of - resolved - target and action attributes). 当它们位于<form>时,Internet Explorer也会为submit按钮显示相同的链接(当然,目标URL是-已解析- targetaction属性的组合)。 Moreover don't forget that default for type attribute in <button> is submit . 此外,请不要忘记<button> type属性的默认值是submit

Solutions 解决方案

First possible solution is to do not use <button> but <input type="button"> to do the trick: IE won't display target URL and you can manually submit your form with JavaScript. 第一种可能的解决方案是不使用<button>而是使用<input type="button">来实现此目的:IE不会显示目标URL,您可以使用JavaScript手动提交表单。

If you need advanced formatting provided by <button> then you can apply same technique: use buttons of type button instead of submit (the default) and IE won't display any tooltip. 如果需要<button>提供的高级格式 ,则可以应用相同的技术:使用类型为button而不是submit (默认),IE不会显示任何工具提示。

HTML (if you need to keep <button> element): HTML(如果需要保留<button>元素):

<button id="btnCancel" type="button">Cancel</button>

Or (if content is just a plain string): 或(如果内容只是纯字符串):

<input id="btnCancel" type="button" value="Cancel"></input>

Or (if you're using Bootstrap and you want to use a link): 或者(如果您使用的是Bootstrap,并且想使用链接):

<a id="btnCancel" class="btn" href="#">Cancel</a>

JavaScript: JavaScript的:

<script type="text/javascript">
    $(document).ready(function () {
        $("#btnCancel").click(function (e) {
            myForm.submit(); 
        });
    });
</script>

Always specify the type attribute for a "button" element. 始终为“按钮”元素指定type属性。 Different browsers use different default types for the "button" element. 不同的浏览器对“ button”元素使用不同的默认类型。 If you do not specify the "type" in button element, browser assumes it a "submit" type and use enclosing "form" element action of the button element. 如果未在按钮元素中指定“类型”,则浏览器将其假定为“提交”类型,并使用按钮元素的封闭“表单”元素动作。 Please refer below link for reference- https://www.w3schools.com/tags/tag_button.asp 请参考以下链接以供参考-https://www.w3schools.com/tags/tag_button.asp

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

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