我搜索了关于同一主题的多个帖子,但这些帖子是几年前的。
我尝试使用以下代码,但仍无法正常工作:
document.getElementById('iframeid').src = document.getElementById('iframeid').src
或
document.getElementById('iframeid').contentWindow.location.reload()
或
document.getElementById('iframeid').contentWindow.location.reload(true)
我的iframe代码是:
<iframe src="./storefront.html" height="100%" width="100%" id="iframeid"></iframe>
我的JS代码是:
function ThemeA(){
var PreHeader = document.getElementById("Pheader");
var PreBody = document.getElementById("PBody");
var PreProduct1 = document.getElementById("ThemeProductList1");
var PreProduct2 = document.getElementById("ThemeProductList2");
var PreProduct3 = document.getElementById("ThemeProductList3");
var PreProduct4 = document.getElementById("ThemeProductList4");
var PreProductStyle1 = document.getElementById("prod1");
var PreProductStyle2 = document.getElementById("prod2");
var PreProductStyle3 = document.getElementById("prod3");
var PreProductStyle4 = document.getElementById("prod4");
PreHeader.className = "PreviewHeader Theme-A-Header-Color Theme-A-Font-Color";
PreBody.className = "PreviewBody Theme-A-Font-Family";
PreProduct1.className = " Theme-A-Product ";
PreProduct2.className = " Theme-A-Product ";
PreProduct3.className = " Theme-A-Product ";
PreProduct4.className = " Theme-A-Product ";
PreProductStyle1.className = "Theme-A-ProductStyle";
PreProductStyle2.className = "Theme-A-ProductStyle";
PreProductStyle3.className = "Theme-A-ProductStyle";
PreProductStyle4.className = "Theme-A-ProductStyle";
document.getElementById('iframeid').contentWindow.location.reload()
}
所有类都已相应设置,但iframe刷新部分无效。