Javascript一直隐藏我的网络背景
Javascript keeps hiding my web background
我的网页加载了背景,然后我点击链接,它像预期的那样给了我我的javascript,但是一旦它完成并输出结果,它就会进入一个空白的白色屏幕,显示我的结果。我希望结果以背景显示在我的网页上。我试了又试,无济于事。这是我的代码:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script type="text/javascript">
function myFunction()
{
var accountnum;
var beginningBal;
var itemsCharged;
var credits;
var creditLimit;
var sum;
accountnum = window.prompt("Enter the account number:");
beginningBal = window.prompt("Enter the beginning balance:");
itemsCharged = window.prompt("Total of all items charged:");
credits = window.prompt("Total credits applied to this account:");
creditLimit = window.prompt("Enter the credit limit: ");
var zero = parseInt (accountnum);
var first = parseInt(beginningBal);
var second = parseInt(itemsCharged);
var third = parseInt (credits);
var fourth = parseInt (creditLimit);
var sum = first + second - third;
var diff = fourth - sum;
if (sum < fourth)
{
document.writeln("<h1>Your account number is:" + zero);
document.writeln("<h1>Your beginning balance is: $" + first);
document.writeln("<h1>Total of items charged: $" + second);
document.writeln("<h1>Total credits applies to this account: $" + third);
document.writeln("<h1>Your credit limit is: $" + fourth);
document.writeln("<h1>Your account balance is: $" + sum);
document.writeln("<h1>Your credit is: $" + diff);
document.getElementById('output').innerHTML = html;
}
else if (sum > fourth)
{
document.writeln("<h1>Your account number is:" + zero);
document.writeln("<h1>Your beginning balance is: $" + first);
document.writeln("<h1>Total of items charged: $" + second);
document.writeln("<h1>Total credits applies to this account: $" + third);
document.writeln("<h1>Your new account balance is: $" + sum);
document.writeln("<h1>Your credit limit is: $" + fourth);
document.writeln("<h1>Your new balance is: $" + diff);
document.writeln("<h1>Your credit is exceeded!");
document.getElementById('output').innerHTML = html;
}
else if (sum == fourth)
{
document.writeln("<h1>Your account number is:" + zero);
document.writeln("<h1>Your beginning balance is: $" + first);
document.writeln("<h1>Total of items charged: $" + second);
document.writeln("<h1>Total credits applies to this account: $" + third);
document.writeln("<h1>Your account balance is: $" + sum);
document.writeln("<h1>Your credit limit is: $" + fourth);
document.writeln("<h1>Your new balance is: $" + diff);
document.writeln("<h1>You are out of credit!");
document.getElementById('output').innerHTML = html;
}
}
</script>
<style>
#output{
height:43px;
}
html{
background: url(images/nxerainbowgrid.jpg) no-repeat center center fixed;
z-index:-9999;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/nxerainbowgrid.jpg', sizingMethod='scale');
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/nxerainbowgrid.jpg', sizingMethod='scale')";
}
</style>
</head>
<body>
<a href="#" onClick="myFunction()"><p>CLICK HERE TO HAVE FUN!!!</p></a>
<div id="output"></div>
</body>
</html>
虽然这不是最好的方法。 或正确的方式。你不应该重复很多代码。并使用提示。以下内容可能是临时解决方案
定义 HTML 并将 CCS 样式更改为正文。 在这种情况下。 背景图像将适合页面的正文
var html;
if(sum<forth){
html ="<h1> Your account number is:" + zero + "</h1>";
html ="<h1>Your beginning balance is: $" + first + "</h1>";
html ="<h1>Total of items charged: $" + second + "</h1>";
html ="<h1>Total credits applies to this account: $" + third + "</h1>";
html ="<h1>Your credit limit is: $" + fourth + "</h1>";
html ="<h1>Your account balance is: $" + sum + "</h1>";
html ="<h1>Your credit is: $" + diff + "</h1>";
document.getElementById('output').innerHTML = html;
}
body{
background: url(index.jpeg) no-repeat center center fixed;
/*keep all other. only change the tag name*/
}
相关文章:
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 通过Magento的网络服务检索运费
- Google/html5语音识别JavaScript SDK Chrome网络工具包SpeechRecognition
- 可以在这里为背景图像设置滤镜吗
- 使用acess代币登录Facebook,并通过网络应用程序离线发布
- 如何使用jquery更改html中的背景颜色
- 使用 js 将背景图像设置为 HTML
- 如何使用密码检测网络中的状态连接
- 使用带括号的图像URL作为jQuery的背景
- 如何使用css动画/javascript使具有背景图像的元素出现
- 循环浏览多个身体背景图像
- 将淡入淡出添加到“我的身体背景滑块”
- ASP.NET网络摄像头显示
- 浮动图像左作为背景-css
- iOS6/7使用网络音频API阻止声音进入背景
- 网络摄像头图片作为背景每60秒更新一次
- 使用网络摄像头作为 HTML 背景
- 使用图论/网络库在节点的背景上绘制图标
- Javascript一直隐藏我的网络背景
- 将网络摄像头转换为拉伸/缩放背景图像