javascript - 如何风格化警告框中的文本?

标签 javascript html css styles

<分区>

Possible Duplicate:
How to get Text BOLD in Alert or Confirm box?

在下面的示例中,我需要为单词 alert 添加样式,因此它显示:

Hello! I am an alert box!

这是我的代码:

<html><head>
   <script type="text/javascript"> 
      function show_alert() 
      {
         alert("Hello! I am an alert box!"); 
      } 
   </script></head><body>
   <input type="button" onclick="show_alert()" value="Show alert box" />
</body></html>

最佳答案

基本上是不可能的。您无权从浏览器内部访问操作系统级别。

您所能做的就是使用自定义模式弹出窗口。您可以找到大量现成的模态弹出插件 herehere

window.alert 接受一个 string 作为参数。您不能设置 string

的样式

来自 MDN :

message is a string of text you want to display in the alert dialog, or, alternatively, an object that is converted into a string and displayed.

关于javascript - 如何风格化警告框中的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7853321/

相关文章:

javascript - 无法获取未定义或空引用的属性 - Windows 8 JS/CSS 应用程序

javascript - 如何使图像 "coming"成为前景

javascript - 如果在 Document Ready 功能中不工作

html - 在 Div 中居中响应式 YouTube 视频

html - 在其他 div 和 anchor 标记中间对齐一个 div

javascript - 通过 Javascript 将字母大写

javascript - 如何在用户点击离开时停止播放视频?

javascript - 如何在 highcharts 轴中实现 "zebra striping"

jquery - 如何克隆单选按钮以将其值传递到表单进程

javascript - 如何在 Div 中按下按钮