Tuesday 15 September 2015

javascript - Change svg options externally -


I have around 100 SVG files, and for everyone I want to change the same thing. This is the original one:

  & lt; svg version = "1.1" id = "Laag_1" xmlns = "http://www.w3.org/2000/svg" xmlns: xlink = "Http://www.w3.org/1999/xlink" x = " 0px "y =" 0px "width =" 460px "height =" 104px "visual box =" 0460104 "able-background =" new 0 0 460 104 "xml: space =" preserve "& gt;   

And I want to change it like this:

  & lt; SVG version = "1.1" id = "Log_l" Ksmlns = "http: // Wwwkv3korg/2000/svg" Ksmlns: Kslink = "Actiteepi://wwwkv3korg/l999/kslink" q = " 0px "y =" preserve 0px "in convulsions =" ​​Aksminyamni See "viewBox =" 0 0 460 104 "able-background =" new 0 0 460 104 "xml: space =" preserve "& gt;   

My HTML code is:

  & lt; Div id = "main" & gt; & Lt; Object width = "100%" data = "http: //euclidthegame.com/mathexchange/7.svg" type = "image / svg + xml" & gt; & Lt; / Object & gt; & Lt; / Div & gt;   

That's why I want to set the default height and width, and I would like to add Asryrashty = "xMinYMin meet" to save. Of course I could only edit all the files, but I would like to use it javascript, jquery or css externally. I'm not sure how I can change attributes in external SVG.

Possible solutions

/ Strong>: To avoid editing 100 SVG files, use this code as inline & lt; Svg & gt; , so to question this.

or tweak the code to insert preserveAccpectRatio: -

  $ aspectRatio = "xMinYMin meet"; $ Svg = $ svg.attr ('preserveAspectRatio', $ aspectRatio);   

Speed ​​: As & lt; Svg & gt; Images are already loaded, a $ (get) Result HTTP Error 304 - Will Not Be Modified and the content will be read from the browser's cache.

No comments:

Post a Comment