本文介绍了Javascript中的警报功能在firefox和chrome中的工作方式不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在验证文本框,当用户没有输入任何内容时,它会显示弹出消息,这个弹出消息在Firefox和Google Chrome中运行良好,但与firefox相比,外观和感觉在chrome中显示不同。 是否有任何替代警报功能在两个浏览器中都相同。
< 表 border = 1 > < tr > ; < td > < asp:标签 ID = lblname runat = server 文字 = 名称: > < / asp:标签 > < / td > < td > < asp:TextBox ID = txtname runat = server > < / asp:TextBox > < / td > < / tr > < tr > < td > < / td > < td > < asp:Button ID = btnnext runat = server Text = 下一步 OnClientClick = validate() / > < / td > < / tr > < / table >< script type = text / javascript language = javascript> function validate(){ if (!document.getElementById( <%= txtname.ClientID%>)。value。匹配(/ ^ [a-zA-Z] + $ /)){ alert( 请输入你的名字); document .getElementById( <% = txtname.ClientID%>中)聚焦(); return false ; } < / script>
解决方案
/)){ alert( 请输入您的姓名); document .getElementById( <% = txtname.ClientID%>中)聚焦(); return false ; } < / script>
是的,外观(外观和感觉)会有所不同,具体取决于浏览器。我建议你使用jQuery插件,你可以在网上找到很多。样本一, jqueryui/dialog/ [ ^ ]
JavaScript警报将具有不同的外观和感觉取决于浏览器渲染.. 对于一个constanct的感觉和外观你可以使用JQUERY弹出窗口。 之一我最喜欢的简单JQUERY弹出窗口如下。 请查看。 [ ^ ] 希望它会有所帮助。 :)
I'm validating a Textbox, when the user doesn't enter anything, it shows a popup message and this popup message working good in Firefox and Google chrome, but the look and feel is showing Differently in chrome when compared to firefox. Is there any alternate for alert function which looks same in both the browsers.
<table border="1"> <tr> <td><asp:Label ID="lblname" runat="server" Text="Name :"></asp:Label></td> <td><asp:TextBox ID="txtname" runat="server"></asp:TextBox></td> </tr> <tr> <td></td> <td><asp:Button ID="btnnext" runat="server" Text="Next" OnClientClick="validate()" /></td> </tr> </table><script type="text/javascript" language="javascript"> function validate() { if (!document.getElementById("<%=txtname.ClientID%>").value.match(/^[a-zA-Z]+$/)) { alert("Please Enter Your Name"); document.getElementById("<%=txtname.ClientID%>").focus(); return false; } </script> 解决方案 /)) { alert("Please Enter Your Name"); document.getElementById("<%=txtname.ClientID%>").focus(); return false; } </script>Yes, the appearance(look & feel) will be different depends upon the browsers. I suggest you to go with jQuery plugins, you could find many in web. Sample one, jqueryui/dialog/[^]JavaScript alert will be having different look and feel depends on the browser rendering.. For a constanct feel and look you can use JQUERY popup. One of my favourite simple JQUERY popup is as follows. Do check it out. [^] Hope it will help. :)
更多推荐
Javascript中的警报功能在firefox和chrome中的工作方式不同
发布评论