2015-05-29 83 views
0

我有兩個x3d文件,即1.x3d12.x3d,我想用按鈕將它們加載到畫布上,但我的代碼似乎不起作用。我在左上方看到加載圖標,但模型不會更改。用按鈕單擊更改x3dom模型

這裏是我的代碼: -

<!DOCTYPE html> 
    <html> 
    <head> 
     <meta http-equiv='Content-Type' content='text/html;charset=utf-8'></meta> 
     <link rel='stylesheet' type='text/css' href='http://www.x3dom.org/x3dom/release/x3dom.css'></link> 
     <script type='text/javascript' src='http://www.x3dom.org/x3dom/release/x3dom.js'></script> 


     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> 
     <script> 
      $(document).ready(function(){ 
      $("button").click(function(){ 
      $("x3d > scene > inline").attr("url", "1.x3d"); 
      }); 
     }); 
     </script> 

    </head> 
    <body> 

     <button> Click to Change Background </button> 

     <x3d id='someUniqueId' showStat='false' showLog='false' x='0px' y='0px' width='400px' height='400px'> 
     <scene> 
      <inline id="myinline" url='12.x3d' ></inline> 
     <scene> 
     </x3d> 
    </body> 
</html> 

回答

0

我測試了它和它的作品,因爲它應該,但你不能測試本地。

XMLHttpRequest無法加載file:/// C:/Users/xxx/Desktop/12.x3d。協議方案僅支持交叉源請求:http,data,chrome,chrome-extension,https,chrome-extension-resource。

+0

我有一個網絡服務器: - http://mytestsite.webatu.com/inline.html。當我點擊更改按鈕時,加載圖標旋轉一秒鐘,然後加載相同的模型。 – anath2