我一直试图在网站上运行Microstrategy报告,并尝试了html和js方法。作为测试,我写了这个(下面的代码),但我一直收到错误,报告没有出现在我的iframe中。我检查了Chrome中的检查员并且一直收到此错误 -
拒绝展示' https://www.microstrategy.com/us/free/express/analytics-express-sign-in?documentID=D3F9920011E43A6B000000802FC73DA5&OrgId=30650#sign-in'在一个框架中因为它设置了X-Frame-Options'到' SAMEORIGIN'。
这是我的代码:
<html>
<body>
<SCRIPT>
function run() {
var sel = document.getElementById('sel');
var idx = sel.selectedIndex;
switch (idx) {
case 0:
document.getElementById('test').style.visibility = "visible";
document.getElementById('test').contentWindow.location.href="https://cloud11.microstrategy.com/MicroStrategy/servlet/mstrWeb?pg=shareAgent&apptype=2&documentID=D3F9920011E43A6B000000802FC73DA5&OrgId=30650&RRUid=1872948";
break;
case 1:
document.getElementById('test').style.visibility = "visible";
document.getElementById('test').contentWindow.location.href="https://cloud11.microstrategy.com/MicroStrategy/servlet/mstrWeb?pg=shareAgent&apptype=2&documentID=D3F9920011E43A6B000000802FC73DA5&OrgId=30650&RRUid=1872948";
break;
default:
document.getElementById('test').style.visibility = "hidden";
}
function hide() {
document.getElementById('test').style.visibility = "hidden";
}
}
</SCRIPT>
<iframe id="test" src="about:blank" width="800" height="500" style="visibility:hidden;">
</iframe>
<br>
<select id="sel">
<option>Report1</option>
<option>Report2</option>
</select>
<br>
<br>
<input type="button" value="Run" onclick="run();"/>
<input type="button" value="Close" onclick="hide();"/>
</body>
</html>
收到错误后,我决定添加&#34; ./"在URL中,但只将其作为错误:
获取文件:/// C:/ wamp / www / ADLScorm / https://cloud11.microstrategy.com/MicroStrateg ... pe = 2&amp; documentID = D3F9920011E43A6B000000802FC73DA5&amp; OrgId = 30650&amp; RRUid = 1872948 net :: ERR_FILE_NOT_FOUND
我该如何解决这个问题?
PS(我最初使用了document.getElementById(&#39; test&#39;)。src。仍然有同样的错误)
答案 0 :(得分:1)
您正面临Cross(X)-Domain安全策略问题。您的网页托管在域A上,您希望将域B加载到iframe中。浏览器不允许这样做。域B必须在其响应头中允许域A.