gpt4 book ai didi

javascript - 使用 javascript 缺少内容更改 html 内容

转载 作者:太空宇宙 更新时间:2023-11-04 10:55:19 25 4
gpt4 key购买 nike

目前我创建了一个页面。该页面将在 safari 浏览器中与 iPod Touch(第 5 代)一起显示。此外,页面应以全屏模式显示。

现在开始着手解决这个问题,但是缺少了一些内容。这是我的起始页 index.html

<!DOCTYPE html>
<html>

<head>
<link rel="stylesheet" type="text/css" href="css/desktop.css">
<link rel="stylesheet" type="text/css" href="css/ipod.css">

<script src="js/jquery-1.11.3.min.js"></script>

<meta name="apple-touch-fullscreen" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>

<body>
<div id="content">
<div id="dumpingStationButtonContainer">
<a id="dumpingStationOneButton" class="dumpingStationButton">Lader&uuml;ssel 1</a>
<a id="dumpingStationTwoButton" class="dumpingStationButton">Lader&uuml;ssel 2</a>
</div>
</div>

<script type="text/javascript">
$(document).ready(function() {
$('#dumpingStationOneButton').click(function() {
$('body').load("dumpingStationOne.html");
});

$('#dumpingStationTwoButton').click(function() {
$('body').load("dumpingStationTwo.html");
});
});
</script>
</body>

</html>

dumpingStationOne.html

<div id="content">
<div id="cameraContainer">
<script type="text/javascript">
var sDomainPort = 80;
var Speck_var = 0;
var channel_s = 0;
var view_w = 900;
var view_h = 675;


if (window.innerWidth > 0) {
window_width = window.innerWidth;
} else {
window_width = screen.width;
}

if (window_width < 981) {
var percent = window_width / view_w;
view_w = window_width;
view_h = percent * view_h;
}

function onLive(sDomainURL, test) {
var ret;
var obj = document.getElementById(test);
obj.Author('admin', 'admin');
obj.SetDateFormat(0);
obj.SingleAudio = 0;
obj.VideoPath = channel_s;
obj.UnderScan = 1;
obj.ROILEFT = 0;
obj.ROITOP = 0;
obj.ROIRIGHT = 0;
obj.ROIBOTTOM = 0;

//var bSuccess = obj.CheckInitState;
//if (bSuccess == 0) {
// setTimeout("onLive();", 1000);
// return;
//}
obj.LivePlay(sDomainURL, sDomainPort, sDomainPort, 0);
}

function closeActiveX(test) {
var obj = document.getElementById(test);
obj.CloseActiveX();
}

document.write('<object id="LiveShow1" classid="clsid:f9bf64a0-5a65-43e0-acdb-b223e7f9ddd9" CODEBASE="WEBWATCH2.cab#version=1,2,5,24" width="' + view_w + '" height="' + view_h + '"> ');
document.write('<img id="camera" width="' + view_w + '" height="' + view_h + '" src="http://192.168.1.195/GetData.cgi?CH=1" alt="Die Verbindung wurde unterbrochen. Bitte warten..."</img>');
document.write('</object>');
</script>
</div>

<div id="operationButtonContainer">
<a id="btnMoveUp" unselectable="on" class="operationButton">Heben</a>
<a id="btnStartStop" unselectable="on" class="operationButton">Start</a>
<a id="btnMoveDown" unselectable="on" class="operationButton">Senken</br></a>
<div id="circleDiv">
<div id="lifeCircle" class="greenCircle"></div>
</div>
<a id="btnBack" unselectable="on" class="operationButton" href="index.html">Zur&uuml;ck</a>
</div>
<div class="clearBoth"></div>
</div>

按钮不见了。而且代码是错误的,我在页面上点击右键->显示代码,页面上的代码是:

<object id="LiveShow1" classid="clsid:f9bf64a0-5a65-43e0-acdb-b223e7f9ddd9" CODEBASE="WEBWATCH2.cab#version=1,2,5,24" width="900" height="675"> <img id="camera" width="900" height="675" src="http://192.168.1.195/GetData.cgi?CH=1" alt="Die Verbindung wurde unterbrochen. Bitte warten..."</img></object>

就是这样。按钮不见了。我做错了什么?谁能帮帮我?

最佳答案

“document.write”替换页面上的所有内容。使用 document.getElementById('myDiv').innerHTML = "text";反而。像这样:

<div id="myDiv"></div>

<script type="text/javascript">
var code = '<object id="LiveShow1" classid="clsid:f9bf64a0-5a65-43e0-acdb-b223e7f9ddd9" CODEBASE="WEBWATCH2.cab#version=1,2,5,24" width="\' + view_w + \'" height="\' + view_h + \'">' +
' <img id="camera" width="\' + view_w + \'" height="\' + view_h + \'" src="http://192.168.1.195/GetData.cgi?CH=1" alt="Die Verbindung wurde unterbrochen. Bitte warten..." </img>\'' +
'</object>';
document.getElementById('myDiv').innerHTML = code;
</script>

关于javascript - 使用 javascript 缺少内容更改 html 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34671498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com