2014-09-19 42 views
0

我一直在嘗試在網站上運行Microstrategy報告,並嘗試過使用html和js方法。作爲一個測試,我寫了這個(下面的代碼),但我不斷收到錯誤,報告沒有出現在我的iframe中。我在Chrome瀏覽器中檢查了檢查器,並且一直出現此錯誤 - 因爲它將'X-Frame-Options'設置爲'SAMEORIGIN',所以拒絕在框架中顯示'https://www.microstrategy.com/us/free/express/analytics-express-sign-in?documentID=D3F9920011E43A6B000000802FC73DA5&OrgId=30650#sign-in'。使用JavaScript和HTML在網站上運行微觀策略報告時出錯

這是我的代碼:

<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,但只得到了這是一個錯誤:

GET文件:///C:/ WAMP/WWW/ADLScorm/https://cloud11.microstrategy.com/MicroStrateg ... PE = 2 & documentID = D3F9920011E43A6B000000802FC73DA5 & ORGID = 30650 & RRUid = 1872948網:: ERR_FILE_NOT_FOUND

請我該如何解決呢?

PS(我最初使用的document.getElementById( '測試')。SRC爲好。還是得到了同樣的錯誤)

回答

1

您所面臨的十字(X) - 域安全策略問題。您的網頁託管在域A上,並且您希望將域B加載到您的iframe中。瀏覽器不允許這樣做。域B必須允許域A在其響應頭中。

+0

請問無論如何我可以解決這個域的安全策略問題? – 2014-09-20 20:55:13