为什么我的变量不显示?我一直工作得很好
Why won't my variables display? It've always worked fine
所以,我已经写了很多次这段代码的副本之前,它已经工作得很好,但现在它只是不想显示我的变量!我已经查看了工作中的html代码中的每一件小事,并将所需的内容复制到我的新文件中,但它就是不想工作……"str"answers"score"应该显示为"Loading…"左上角是0",但是没有,什么都没有…下面是代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Loading...</title>
<style>
body{
font-size:20px;
margin:0;
overflow:hidden;
}
#str{
display:block;
font-size:30px;
position: fixed;
top: 1.0em;
left: 1.0em;
user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
}
#str:hover{
text-decoration: underline;
cursor: pointer;
}
#score{
display:block;
font-size:30px;
position: fixed;
top: 2.0em;
left: 1.0em;
user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
}
#score:hover{
cursor: default;
}
#blackBox{
background-color:black;
display:block;
position:fixed;
width:0.1%;
bottom:4.0em;
left:0.0em;
padding:0.5em 0em;
text-align:left;
vertical-align:top;
border:2px solid black;
}
#blackBox2{
display:block;
position:fixed;
width:99.5%;
bottom:4.0em;
left:0.0em;
padding:0.5em 0em;
text-align:left;
vertical-align:top;
border:2px solid black;
}
</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-33914917-1']);
_gaq.push(['_setDomainName', 'dhmholley.co.uk']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body onload="initialise()">
<div id="blackBox"></div>
<div id="blackBox2"></div>
<script>
var prc = 0,
W = 1,
function initialise(){
createInterface();
updateScore();
}
function mload(){
prc = prc + 1;
W = prc / 100;
document.getElementById("blackBox").style.width = W + "%";
updateScore();
}
function createInterface(){
var score = document.createElement('div');
score.id = 'score';
score.innerHTML = prc;
document.body.appendChild(score);
var str = document.createElement('div');
str.id = 'str';
str.innerHTML = 'Loading...';
str.onclick = function(){
mload();
}
document.body.appendChild(str);
}
function updateScore(){
document.getElementById('score').innerHTML = prc;
}
</script>
</body>
</html>
你可以用一个var语句声明多个变量,但是你必须用一个;! 有可能离开它,但我不会(有很好的例子:
//not good but should work:
var a,b
function c(){}
//the best solution:
var a,b;
function c(){};
//what you did
var a,b,function c(){};
//wich is invalid
相关文章:
- Javascript:selenium Web驱动程序isDisplayed()不工作
- jQuery UI自动完成突然停止工作
- AngularJS UI路由器不能像ng路由器那样工作
- HTML5音频加载和播放获胜'我不能在iPad上工作
- JavaScript打印功能使日历停止工作
- Javascript.getHours()工作不正常
- 为什么这在IE中的工作方式与在Firefox中不同
- 视频HTML没有'无法在Internet Explorer 11上工作
- 扩展移相器按钮类不工作
- Firebase迁移-简单的Firebase.set没有'不再工作了——旧的还是新的
- 谷歌地图不是以HTML显示,而是在JS Fiddle上工作
- 正在尝试使用if和else添加类,但无法正常工作
- Jquery FadeIn FadeOut 只工作一次
- Foreach无法在Typescript中工作
- 溢出:滚动;jquery在停止工作后一直滚动到某个时刻
- JS一直工作到我把它带入一个基础框架
- javascript没有'I don’我一直在IE工作
- 这个结构能一直工作吗
- window.onload没有'I don’我不能一直工作.为什么?
- 为什么我的变量不显示?我一直工作得很好