我正在尝试使用我的主页引用其他页面,并使用JavaScript更改该页面及其标题的iframe中的内容。当我已经在页面中时,我可以更改内容,但是当我从主页引用时,它不会更改iframe的内容。
EntryForm.html是'主表单页面'当用户从主页单击按钮时,需要能够更改iframe和标题的内容。任何帮助表示赞赏。
首页HTML页面
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"content="HTML,CSS,XML,JavaScript">
<script src="Scripts/jquery.js" type="text/javascript"></script>
<script src="Scripts/Global.js"></script>
<script type="text/javascript" src="lib/d3.js"></script>
<script type="text/javascript" src="Scripts/gauge.js"></script>
<link rel="stylesheet" type="text/css" href="Styles/Design.css">
</head>
<body onload="initialize()">
<div id="body"><br></div>
<div id="header">
<h1>Carrolton Plant</h1>
<div id="headerIcon"></div>
<div id="tv1clock"></div>
</div>
<div id="content"> </div>
<span id="oeeLine1GaugeContainer"></span>
<span id="oeeLine2GaugeContainer"></span>
<span id="oeePlantGaugeContainer"></span>
<span id="testGaugeContainer"></span>
<div id="footer">
<input title="Home Page" type="homebutton"></input>
<input title="Previous Page" type="previousbutton" onclick="PreviousPage()"></input>
<a href ="EntryForm.html"onclick="WastePage()"> <input title="Waste Entry Page" type="wastebutton" onclick="WastePage()"></input></a>
<a href ="EntryForm.html" onclick="MetricsPage()"> <input title="Metrics Initializer" type="gearbutton" onclick="MetricsPage()"></input></a>
<a href="HeatMap.html"><input title="Heat Map" type="heatbutton"></input></a>
<a href ="EntryForm.html" onclick="SafetyEntryPage()"> <input title="Safety Entry" type="safetybutton" onclick="SafetyEntryPage()"></input></a>
<input title="Trending" type="trendbutton" onclick="Trending()"></input>
<input title="Alarm and Events" type="alarmbutton" onclick="Alarm()"></input>
<input title="Report Expert" type="expertbutton" onclick="ReportExpert()"></input>
<input title="Data Entry Reports" type="ssrsbutton" onclick="DataEntrSSRS()"></input>
</div>
</body>
</html>
报名表
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" content="HTML,CSS,XML,JavaScript">
<script src="Scripts/jquery.js" type="text/javascript"></script>
<script src="Scripts/Global.js" type="text/javascript"></script>
<script type="text/javascript" src="Scripts/modernizr.custom.86080.js"></script>
<link rel="stylesheet" type="text/css" href="Styles/Design.css">
</head>
<body>
<div id="header">
<h1 id="h1">Metrics Entry Form</h1>
<div id="headerIcon"></div>
<div id="tv1clock"></div>
</div>
<center>
<div id="wrapper">
<div id="iFrameHeight">
<iframe name="iframe" src="MetricsEntryForm.html" scrolling="auto" id="GlobalFrame"></iframe>
</div>
</div>
</center>
<div id="footer">
<a href="HomePage.html"><input title="Home Page" type="homebutton"></input></a>
<input title="Previous Page" type="previousbutton" onclick="PreviousPage()"></input>
<input title="Waste Entry Page" type="wastebutton" onclick="WastePage()" ></input>
<input title="Metrics Initializer" type="gearbutton" onclick="MetricsPage()"></input>
<a href="HeatMap.html"><input title="Heat Map" type="heatbutton"></input></a>
<input title="Safety Entry" type="safetybutton" onclick="SafetyEntryPage()" ></input>
<input title="Trending" type="trendbutton" onclick="Trending()"></input>
<input title="Alarm and Events" type="alarmbutton" onclick="Alarm()"></input>
<input title="Report Expert" type="expertbutton" onclick="ReportExpert()"></input>
<input title="Data Entry Reports" type="ssrsbutton" onclick="DataEntrSSRS()"></input>
</div>
</body>
</html>
的JavaScript
function WastePage() {
document.getElementById("h1").innerHTML = "Waste Entry Form";
document.getElementById("GlobalFrame").src = "WasteEntryForm.html";
}
function SafetyEntryPage() {
document.getElementById("h1").innerHTML = "Safety Entry Form";
document.getElementById("GlobalFrame").src = "SafetyEntryForm.html";
}
function MetricsPage() {
document.getElementById("h1").innerHTML = "Metrics Entry Form";
document.getElementById("GlobalFrame").src = "MetricsEntryForm.html";
}
答案 0 :(得分:1)
将iframe移至主页并完全删除Entry.html页面。考虑到你想要做的事情,那个页面似乎毫无价值。然后从“废物”,“度量标准”和“安全性”链接中删除锚标记。这是更新的home.html:
<div id="body"><br></div>
<div id="header">
<h1>Carrolton Plant</h1>
<div id="headerIcon"></div>
<div id="tv1clock"></div>
</div>
<div id="content">
<center>
<div id="wrapper">
<div id="iFrameHeight">
<iframe name="iframe" src="MetricsEntryForm.html" scrolling="auto" id="GlobalFrame"></iframe>
</div>
</div>
</center>
</div>
<span id="oeeLine1GaugeContainer"></span>
<span id="oeeLine2GaugeContainer"></span>
<span id="oeePlantGaugeContainer"></span>
<span id="testGaugeContainer"></span>
<div id="footer">
<input title="Home Page" type="homebutton"></input>
<input title="Previous Page" type="previousbutton" onclick="PreviousPage()"></input>
<input title="Waste Entry Page" type="wastebutton" onclick="WastePage()"></input>
<input title="Metrics Initializer" type="gearbutton" onclick="MetricsPage()"></input>
<a href="HeatMap.html"><input title="Heat Map" type="heatbutton"></input></a>
<input title="Safety Entry" type="safetybutton" onclick="SafetyEntryPage()"></input>
<input title="Trending" type="trendbutton" onclick="Trending()"></input>
<input title="Alarm and Events" type="alarmbutton" onclick="Alarm()"></input>
<input title="Report Expert" type="expertbutton" onclick="ReportExpert()"></input>
<input title="Data Entry Reports" type="ssrsbutton" onclick="DataEntrSSRS()"></input>
</div>
同时将此功能添加到您的javascript文件
function HomePage() {
document.getElementById("h1").innerHTML = "Carrolton Plant";
document.getElementById("GlobalFrame").src = "MetricsEntryForm.html";
}
这就是我要做的事。