我正在寻找 simple javascscript 警告框。我需要能够向警告框传递一串文本。
这样的事情可能吗?我的语法可能有误。
<html>
<head>
<script type="text/javascript">
function show_alert()
{
alert(my_string_here);
}
</script>
</head>
<body>
<input type="button" onclick="show_alert()" value="Show alert box" string="alert for system number 2" />
</body>
</html>
最佳答案
<html>
<head>
<script type="text/javascript">
function show_alert(my_string)
{
alert(my_string);
}
</script>
</head>
<body>
<input type="button" onclick="show_alert('This will alert!')" value="Show alert box" string="alert for system number 2" />
</body>
</html>
你这没有意义。更好的解决方案:
<html>
<head>
</head>
<body>
<input type="button" onclick="alert('Doh!')" value="Show alert box" string="alert for system number 2" />
</body>
</html>
关于variables - 传递 Javascript Alert 一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1676570/