如何在警报框中设置文字样式? [英] How to stylize text in an alert box?
问题描述
可能重复:
如何在警告"或确认"框中获得加粗的文字?
在下面的示例中,我需要在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.
这篇关于如何在警报框中设置文字样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!