2017-04-19 189 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文件........