У меня есть HTML-страница, сделанная из вкладок jquery. Каждая вкладка загружает данные с другой HTML-страницы. Я устанавливаю глобальную переменную на странице HTML-контейнера, и я хочу получить доступ к тому же на ее вкладках. Как я могу это сделать? Я пробовал window.var, window.parent.var, this.var и т. Д. Но ничего не работает. Я приложил код. любезно помогите.
Контейнер html page.
<html>
<head>
<link type="text/css" href="../../css/ui-lightness/jquery-ui-1.8.14.custom.css" rel="Stylesheet" />
<link type="text/css" href="./methodeditor.css" rel="stylesheet" />
<script type="text/javascript" src="../../js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="../../js/jquery-ui-1.8.14.custom.min.js"></script>
<script>
$(function() {
$( ".tabs" ).tabs({cache:true});
});
</script>
<script>
var method = " ";
function setmethod(m) {
method = m;
}
function loadtabs(){
method = window.parent.method;
setmethod(method);
$("#oven").load('oven.html');
$("#detectors").load('detectors.html');
$("#inlets").load('inlets.html');
}
</script>
</head>
<body>
<form id="editor" action="method.php" method="POST" >
<div class="editor">
<div class="tabs">
<ul>
<li><a href="#oven">Temperature</a></li>
<li><a href="#detectors">Timing</a></li>
<li><a href="#inlets">Vial and Loop</a></li>
</ul>
<div id="oven" ></div>
<div id="detectors" ></div>
<div id="inlets"> </div>
</div>
<script>
loadtabs();
</script>
</form>
</div>
</body>
</html>
oven.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script>
function getvalues() {
file = window.method;
//file = m;
file = "./method/"+file;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", file, false);
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.send("");
xmldoc = xmlhttp.responseXML;
etimenode = xmldoc.getElementsByTagName("method")[0].childNodes[1].childNodes[1];
etime = etimenode.textContent;
document.getElementById("etime").value = etime;
}
</script>
</head>
<body>
<input type="checkbox" name="oventemp" value="ON" />Oven Temperature
Equilibrium time <input type="text" id="etime" />
<script>
getvalues();
</script>
</body>
</html>