使用Javascript和HTML在网站上运行微观战略报告时出错

Error running a microstrategy report on website using Javascript and HTML

本文关键字:微观 报告 出错 运行 Javascript HTML 网站 使用      更新时间:2023-09-26

我一直在尝试在网站上运行MicroCategory报告,并尝试了html和js方法。作为测试,我写了这个(下面的代码),但我不断收到错误,报告没有出现在我的iframe中。我在Chrome中检查了检查员,并不断收到这个错误-

拒绝显示'https://www.microstrategy.com/us/free/express/analytics-express-sign-in?documentID=D3F9920011E43A6B000000802FC73DA5&OrgId=30650#在帧中登录",因为它将"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>

在得到这个错误后,我决定在URL中添加"./",但只得到了一个错误:

得到file:///C:/wamp/www/ADLScorm/https://cloud11.microstrategy.com/MicroStrateg…pe=2&documentID=D3F9920011E43A6BB000000802FC73DA5&OrgId=30650&RRUid=1872948净::ERR_FILE_NOT_FOUND

请问我该如何解决这个问题?

PS(我最初也使用document.getElementById('test').src。仍然得到相同的错误)

您正面临跨(X)域安全策略问题。您的页面托管在域A上,并且您希望将域B加载到您的iframe中。浏览器不允许这样做。域B必须在其响应标头中允许域A。