如何在警报框中设置文字样式?

编程入门 行业动态 更新时间:2024-10-12 03:28:00
本文介绍了如何在警报框中设置文字样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

可能重复: 如何在警告"或确认"框中获得加粗的文字?

在下面的示例中,我需要在Alert一词中添加样式,因此它表示为:

In the following example I need to add styles to the word alert, so it says:

你好!我是一个警报框!

这是我的代码:

<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>

推荐答案

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

Basically it's impossible. You don't have access to OS level from inside the browser.

您所能做的就是使用自定义模式弹出窗口.您可以在此处找到大量准备使用的模式弹出插件.或此处

All you can do is using a custom modal popup. You can find tons of ready to use modal popup plug ins here or here

window.alert 接受 string 作为其参数.您无法设置 string

window.alert accept an string as it's argument. You can't style an string

来自 MDN :

消息是要在警报对话框中显示的文本的 string ,或者,也可以将一个对象转换为字符串,然后显示.

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.

更多推荐

如何在警报框中设置文字样式?

本文发布于:2023-10-19 18:54:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1508451.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   框中   样式   文字   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!