jss 文件中的 Javascript 警报功能
我有一个问题,当我单击网页上的按钮时,我想在警报框中显示一堆变量。
我不想在 XHTML 文件中创建一堆变量然后输出这些变量,因为我已经计算了 javascript 文件中的所有内容。我将 Javascript 文件引用到我的 XHTML 文件,如果我只是做一个普通的 document.write ,变量就会显示出来。
变量只是我根据一系列值计算的数字。当我单击网页本身上的按钮时,我想将它们显示在警报框中。现在,当我访问网页时,我可以在警报框中显示它们,但是当我单击按钮时,我不知道如何显示它们。
例如:
我的 .jss 文件包含以下内容:
var num5 = 5;
var num6 = 6;
var num7 = 7;
var num8 = 8;
var num9 = 9;
var num10= 10;
我的 xhtml 文件:
<?xml version = "1.0" encoding = "utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtmll/DTD/xhtmll-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>ShowNums.html</title>
</head>
<body>
<script type = "text/javascript" src = "test.js">
</script>
<input type="button" onclick="show_alert()" value="Click" />
</body>
</html>
我将 .jss 文件引用到 XHTML 文件并希望显示这些数字。我可以轻松地将它们编码到警报中,但我宁愿有一个弹出警报框,当用户单击按钮(即“单击”按钮)时会显示它们。我该怎么做?我尝试寻求帮助,但似乎找不到:\
I have a problem where I want to show a bunch of variables in an alert box when I click on a button on the webpage.
I don't want to create a bunch of variables in a XHTML file and then output those since I already calculated everything in my javascript file. I referenced the Javascript file to my XHTML file and the variables show up if i just do a plain document.write
The variables are just numbers I calculated on a range of values. I want to display them in an alert box when I click on a button on the webpage itself. Now I can display them in an alert box when I go to the webpage, but I can't figure out how to display them when I click on a button.
For example,:
My .jss file contains the following:
var num5 = 5;
var num6 = 6;
var num7 = 7;
var num8 = 8;
var num9 = 9;
var num10= 10;
My xhtml file:
<?xml version = "1.0" encoding = "utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtmll/DTD/xhtmll-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>ShowNums.html</title>
</head>
<body>
<script type = "text/javascript" src = "test.js">
</script>
<input type="button" onclick="show_alert()" value="Click" />
</body>
</html>
I referenced my .jss file to my XHTML file and want to display those numbers. I can easily encode them into an alert but I would rather have a popup alert box that would display them when the user clicks on a button(i.e. the Click button). How would I do this? I tried looking for help but I can't seem to find it :\
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只是在寻找这个
show_alert()
函数吗?Are you just looking for this
show_alert()
function?