2017-04-19 99 views
0
 I have create one HTML page like 
<html style="overflow: hidden;"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title>SVG file</title> 
     <meta name="viewport" content="width=device-width,initial-scale=1.0"> 
     <link rel="stylesheet" href="./default.min.css"> 
     <link rel="stylesheet" href="./style.css"> 
     </head> 
     <body> 
     <main> 
       <div class="slider HSlider" style="position: relative; width: 100%; height: 100%; transform: translate3d(0%, 0px, 0px);> 
        <section class="section active" data-index="1" style="position: absolute; width: 100%; height: 100%; left: 0%;"> 
         <article > 
          <div class="slide-head"> 
           <h1>Load SVG file</h1> 
          </div> 
         </article> 
         <img src="./01.svg" style="min-width: 100%; position: absolute; bottom: -5vh; z-index: 1;"> 
        </section> 
     </main> 
     </body> 
     </html>  

和我的第二個文件是01.svg像如何加載外部JavaScript文件中的SVG文件

 <?xml version="1.0" encoding="UTF-8"?> 
     <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> 
     <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="11.6917in" height="4.06969in" version="1.1" style="shape-rendering: geometricPrecision; text-rendering: geometricPrecision; image-rendering: optimizeQuality; fill-rule: evenodd; clip-rule: evenodd" viewBox="0 0 11692 4070" enable-background="new 0 0 500 500" x="0px" y="0px" xmlns:xlink="http://www.w3.org/1999/xlink">  
     <defs> 
     load css 
     </defs> 
     </svg> 

我有HTML頁面內加載SVG文件並正確的工作,但現在我需要設置一些動畫對svg的影響,我嘗試在svg和HTML頁面中加載JavaScript,但它無法工作。

我也嘗試加載的JavaScript在SVG文件一樣

 <script type="text/JavaScript" xlink:href="./index.js" /> 

但它不能正常工作。

所以有人知道如何在這種情況下加載JavaScript?

+0

01.svg必須由一個文件,它不能加載任何東西,因爲它被用作圖像。即使它可以加載文件,圖像也無法運行JavaScript。 –

回答

0

我得到了答案

我剛剛更換標籤在我的html頁面標記,並在我的01.svg文件加載javascript文件........