我有两个html页面(index.html和game.html)第二页(game.html)包含一个html代码,它将使用js代码填充。
首先,当我打开index.html时,当我移动到game.html时没有错误我在控制台中收到此错误:
tag does not match. Expected: </ meta> game.html: 16: 7
当我返回index.html时,我在控制台中收到此错误:
tag does not match. Expected: </ meta> index.html: 16: 7
我的问题是,当我转移到game.html时,js代码无法正常工作,刷新页面后,每件事情都运行正常,页面已填满
当我用game.html启动我的应用程序时,每件事都运行正常。 我的问题开始如果我使用index.html启动我的应用程序,然后转到game.html页面
1-像这样的关闭元标记
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
上面的错误消失但js代码在我刷新页面之前不起作用
2-从game.html中删除JS代码 但错误仍然存在
3-更改我正在处理的QCM.js文件的内容但问题仍然存在(确保没有javascript错误)
这是index.html:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" href="css/base.css" type="text/css" />
<link rel="stylesheet" href="css/jquery.mobile.structure-1.4.5.css" />
<link rel="stylesheet" href="css/jquery.mobile-1.4.5.css" />
<title> sounds </title>
</head>
<body dir="rtl" lang='ar' class="contentBack">
<div data-role="page" id="homefa" data-theme="a" >
<div data-role="header" data-theme="b">
<h1 id="TitleHeader" style=""> sounds </h1>
</div>
<div data-role="content">
<div id="outer" style="">
<div class="menu_simple" align="center" style="">
<ul>
<li><a data-transition="slidedown" style="font-family:mySecondFont;text-align:center;" href="game.html"> Start game </a></li>
</ul>
</div>
</div>
</div>
</div>
<script src="js/jquery-1.11.3.js"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src="cordova.js"></script>
</body>
</html>
这是game.html(即使删除了正文内容后错误仍然存在):
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" href="css/base.css" type="text/css" />
<link rel="stylesheet" href="css/jquery.mobile.structure-1.4.5.css" />
<link rel="stylesheet" href="css/jquery.mobile-1.4.5.css" />
<title> sounds </title>
</head>
<body dir="rtl" lang='ar' class="contentBack" >
<div data-role="page" id="gameTT" data-theme="a" >
<div data-role="header" data-theme="b">
<a style="margin-top:13px;margin-left:10px;color:white;" href="#" data-rel="back" >رجوع</a>
<h1 id="TitleHeader" style="" > sounds </h1>
</div>
<div data-role="content">
<div align="center" >
<h1 id="QuestNum" style="font-family:mySecondFont;text-align:center;"> </h1>
<div id="soundDIV">
<input type="image" id="pauseMp3" class="inline " src="img/pause.png" alt="click" height="65" width="65"/>
<input id="playMp3" type="image" class="inline " src="img/play.png" alt="click" height="65" width="65"/>
</div>
</div>
<br/><br/>
<div class="section group" >
<div id="col0" style="text-align:center;" class="col span_1_of_3">
</div>
<div id="col1" style="text-align:center;" class="col span_1_of_3">
</div>
<div id="col2" style="text-align:center;" class="col span_1_of_3">
</div>
</div>
<div class="section group" >
<ul id="choice-block">
</ul>
</div>
<div id="Why"></div>
<div id="frame" >
</div>
</div>
</div>
<script type="text/javascript" src="js/sounds.js" ></script>
<script type="text/javascript" src="cordova.js"></script>
<script src="js/jquery-1.11.3.js"></script>
<script type="text/javascript" src="js/QCM.js" ></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
</body>
</html>
QCM.js文件就像这样
jQuery(document).ready(function($){
// for example to add a button to game.html
$(document.createElement('div')).addClass('choice-box').attr('id', 'submitbutton').text('check').appendTo('#frame');
});