ã€ã³ã¿ãŒãããäžã®ãã¯ã¿ãŒã°ã©ãã£ãã¯ã¹ã®å Žåã
SVG圢åŒã¯ãŸãã«ããã§ãã ãŸããããããçšåºŠã®ã¹ã±ãŒãªã³ã°ããµããŒãããŸãã 第äºã«ãããªãã¯ãã®ãããªçµµã®æ§æèŠçŽ ãåç
§ããããšãã§ããŸã-ãããã«å¯ŸåŠããæ§åŒåããã¹ã¯ãªããåããŸãã 第äžã«ãéåžžã«å°ããªãã¡ã€ã«ãé€ãããã®åœ¢åŒã¯ãç¹ã«gzipå§çž®ã䜿çšãããŠããå Žåãã©ã¹ã¿ãŒè¡šçŸãããã³ã³ãã¯ãã«ãªããŸãã 第4ã«ãããã¯
W3Cæšæºã§ãã
ãããã
SVGç»åã
HTMLããã¥ã¡ã³ãã«å
¥ããæ¹æ³ã¯ïŒ
HTMLã«SVGãåã蟌ãæ¹æ³
3ã€ã®æ¹æ³ãããããšãç¥ãããŠããŸãã
- ã³ãŒãã«çŽæ¥ïŒãã ã-ãããããïŒ-IEã¯ãã®ã¡ãœãããåãå
¥ãããä»ã®ãã©ãŠã¶ã¯XHTMLããã¥ã¡ã³ãã§ã®ã¿èš±å¯ããŸãããããã¯åžžã«å¯èœã§ã¯ãããŸããïŒ;
iframe
ãããŒãã£ã³ã°ãã¬ãŒã ã«iframe
ããŸããïŒãã¬ãŒã ã¯æ代é
ãã®æªã§ãããšèãããããè©ŠããŠããããŸããã§ããïŒãobject
ã¿ã°ã䜿çšãobject
ïŒããã¯ç§ãã¡ãè¡ãããšã§ãïŒã
æåã®é©ãã¯ç§ãã¡ãæ瀺ããŸã...ã©ã®ãã©ãŠã¶ãæšæž¬ããŸããïŒ ãã¡ããããã®
IEã§ã¯ã
object
ã¿ã°
SVG- pictureã䜿çšããçµã¿èŸŒã¿ã¹ã¯ãªããã¯èš±å¯ãããŠãããããã®éæãªèæ¯ãçœã§å¡ãã€ã¶ããŠããŸãïŒ å¹žããªããšã«ããããã®ç®çã®ããã«ç¬èªã®
embed
ã¿ã°ãæäŸããŸãã æ¡ä»¶ä»ãã³ã¡ã³ããšã¹ã¿ã€ã«å¶åŸ¡ã«ãããéåžžã®ãã©ãŠã¶ã
object
èŠçŽ ãä»ããŠ
SVGã衚瀺ãã
embed
ä»ããŠ
IEã衚瀺ããããšãå®çŸããããšã¯ç°¡åãã€æå¹ã§ãã ããããããã§ããããïŒ
2çªç®ã®é©ãïŒãã©ã°ã€ã³ïŒ
Adobe SVG Viewerãªã©ïŒãã€ã³ã¹ããŒã«ãããŸã§ãããªããŸããã 確ãã«ã
Adobeã¯2009幎1æ1æ¥ã«ãµããŒããåæ¢ããããã§ããããã§ã«è¡ãããããšã§ååã§ãããæçµçã«ã¯Internet Explorerããã³
Ssrc SVG Pluginçšã®RENESIS Player 1.0ããããŸãã ããã«ã
1999幎ã«W3CãVMLãæå
¥ããMicrosoftãã©ã®ãã
ã«æ»æ
ããããšããŠãã Googleã
Wikimedia Foundationãªã©ã®åœå±ã¯ã
ãã€ãã£ãSVGãµããŒããå°å
¥ ãã ããã«ãã ã å解 ã ãŠããŸãã
Habré㮠ã
MicrosoftãW3Cçµç¹ã§SVG圢åŒãéçºããããã®ã¯ãŒãã³ã°ã°ã«ãŒããžã®åå ãç³è«ããããšããå±ãŸãã®
ãã¥ãŒã¹ã¯ãã§ã«
è°è«ã
ããŠããŸãã 楜芳䞻矩ã«ã¯ããããçç±ããããŸãã
次ã ã€ã³ã¿ãŒãããäžã®å€ãã®å Žæã«ãã
embed
ã¿ã°ã®èª¬æã§ã圌ããã®ãããªçŽ æŽããã
pluginspage
å±æ§ãæã¡ãã¢ãã¬ã¹ã瀺ããŠãããšèªãããšãã§ããŸããã¢ãã¬ã¹ã¯ããããã
ãã©ãŠã¶ãSVGã°ã©ãã£ãã¯ã¹ããµããŒãããªãå Žåã«ãŠãŒã¶ãŒã«éä¿¡ãããŸãã
ä¿¡ããªãã§ïŒ ããã¯3çªç®ã®é©ãã§ããå®éã«ã¯ã
IEã¯ãã®å±æ§ãç¡èŠããŸãã
ãããŠããããæ©èœãããããã«ãJScriptããã³
VBScriptã®ã¹ã¯ãªããã䜿çšãããéåžžã«ã»ãšãã©ç¥ãããŠããªãïŒã€ã³ã¿ãŒãããäžã®äž»é¡è³æã«ãªã³ã¯ããŸã£ãããªãããšããå€æïŒ
ããªãããŒãªæ¹æ³ããããŸãã ååãšããŠã倧äžå€«ã§ãããããªãã¯ããã«ã€ããŠç¥ãå¿
èŠããããŸãã
ã¢ãããœãªã¥ãŒã·ã§ã³ã®ã¢ããã°ã¬ãŒã
ãããã解決çã¯å®å
šã«è¯ããšããããã§ã¯ãããŸããã 第äžã«ãããã¯æå¹ã§ã¯ãªãã第äºã«ã誰ã䜿çšããŠããªãããã€ãã®æ§åŒã®ãã©ãŠã¶åãã«èšèšãããŠããŸããã第äžã«ãææ°ã®ãã©ãŠã¶ã§ã¯åäœããŸããïŒå³å¯ã«ã¯ããã©ãŒã ã§ã¯ãŸã£ããåäœããŸããäžãããããã®ïŒã ãã ãããœãªã¥ãŒã·ã§ã³ã®åºæ¬çãªèãæ¹ã¯æ£ãããããå®çšçã§ã¢ãã³ãªãã®ã«ããããšããŸãã
ãŸã第äžã«ããã®è¡ã«ã¯åé¡ããããŸãã
<script language="JavaScript"> </script>
é¢æ°ã¯ãåŒã³åºããæ°ããè¡ã«è»¢éããªãéãããã®äžã§å®è¡ãããŸããã
XHTMLã§ã®ã¿ãšã¹ã±ãŒããããã«å°é£ã«ãªããããå€éšã¹ã¯ãªãããžã®é¢æ°åŒã³åºããè¡ãããšãã§ããŸãã
<script language="JavaScript" src="viewSVJ.js"></script>
ç¶ããŸãããã çŸåšã®ã³ãŒãã§ã¯ãFirefoxãChromeãSafariã«ã¯
SVGã衚瀺ããããã®ãã©ã°ã€ã³ãå¿
èŠã§ãããšèããããŠãããOperaã¯äžè¬çã«ãã®ç¹ã§çµ¶æçã§ãã ãã ããOperaã¯ããŒãžã§ã³8.0ïŒ2005幎4æ19æ¥ïŒãFirefox-ããŒãžã§ã³1.5ïŒ2005幎11æ30æ¥ïŒãSafari-ããŒãžã§ã³3.0ïŒ2007幎6æ11æ¥ïŒãChrome-èªçïŒ
SVG 2008幎9æ2æ¥ïŒã å®éããInternet ViewerããŸãã¯Internet Explorerã«ã®ã¿å¿
èŠãªãã¹ãŠã®ããªãã¯ã¯ããã®ãããªãµããŒãã9çªç®ã®ããŒãžã§ã³ã§ã®ã¿æåŸ
ãããŠããŸãã
ãã®åŸãæ¥ç¶ããã3ã€ã®ã¹ã¯ãªããã¯ãã¹ãŠãæ¡ä»¶ä»ãã³ã¡ã³ãã§ä»ã®ãã©ãŠã¶ãŒããé衚瀺ã«ã§ããŸãïŒããã¯JavaScriptã§ãããšåœè£
ããèšèªã«ã€ããŠã§ãïŒã
<!--[if IE]> <script language="JScript" src="svgcheck.js"></script> <script language="VBScript" src="svgcheck.vbs"></script> <script language="JScript" src="viewSVJ.js"></script> <![endif]-->
SVGç»åãçŽæ¥æ¥ç¶ãããŠããå Žåãæšå¥šãããã³ãŒããåãã³ã¡ã³ãã§å²ã¿ã次ã®ããã«èšè¿°ã§ããŸãã
<object type="image/svg+xml" data="hello.svg" height="200" width="600"></object>
èŠããã«ãããé¢åãªãã¶ã€ã³ãåŸãããæ¯ãèããšæ··åããè¡šçŸããåŸãããŸãã å®éã次ã®ããã«æžãããšãã§ããŸãã
<object type="image/svg+xml" data="hello.svg" height="100" width="100"></object>
ãŸãã
viewSVJ.js
ãã©ã°ã€ã³ã¹ã¯ãªããã§ã¯ã
SVGãã©ã°ã€ã³ããŸã ã€ã³ã¹ããŒã«ãããŠããªãå Žåã
embed
èŠçŽ ãå埩åŠçãããªã³ã¯ä»ãã®èŠåã«çœ®ãæããŸãã
checkAndGetSVGViewer(); window.attachEvent( "onload", function(){ if(window.svgInstalled)// SVG- return; var embeds=document.getElementsByTagName("embed"); for(var embedNumber=0, embedTypeAttr; embedNumber<embeds.length; embednumber++){ embedtypeattr=embeds[embedNumber].attributes["type"]; if(embedtypeattr="image/svg-xml" || embedtypeattr.value="image/svg-xml") embeds[embednumber].outerhtml="<p>To view this page you need an SVG viewer. <a href=\""+getSVGInstallPage()+"\">Click here</a> for more information.</p>"; } } );
ãããã
HTMLã³ãŒãã¯ãŸã è¥å€§åããããŠããŸãã çµå±ã®ãšããã
embed
èŠçŽ ãå«ãæ¡ä»¶ä»ãã³ã¡ã³ãã¯ãå
SVGç»åãããã³ããã€ãã®ã¹ã¯ãªãããžã®ãªã³ã¯ïŒããã³æ¡ä»¶ä»ãã³ã¡ã³ããå«ãïŒãèšè¿°ããå¿
èŠããããŸãã ãã¡ãããæšæºåã¯ãããŸãã...ããã«ããããã®ã¹ã¯ãªããã¯ã°ããŒãã«ãªåå空éãæ£ããããå€ãã³ãŒããæŽçããããããŸããã
æåã«ã¹ã¯ãªããã飌ããªãããŸãã 1ã€ã®
fixSVG.js
ã¹ã¯ãªãããããŒãžã«ããã¯ããŸã
fixSVG.js
å Žåã¯ãåçã«äœæããããããŒãã£ã³ã°ãã¬ãŒã ã«èªã¿èŸŒãç¬èªã®ãã©ã³ããäœæããŸãïŒã¯ããç§ã¯åœŒãã®ã¢ãã¬ã¹ã§éŒ»ã鳎ãããŸããããããã¯ãããŸã§ã«æé©ãªãã©ãŠã¶ãŒãœãªã¥ãŒã·ã§ã³ã§ãïŒïŒ ãEdoubyãïŒAdobeïŒã®ã¹ã¯ãªããã ãããã䜿çšããŠãã€ã³ã¹ããŒã«ããã
SVGãã©ã°ã€ã³ã®ååšã確èªããŸãã ã€ã³ã¹ããŒã«ãããŠããªãå Žåã¯ãç»åããªã³ã¯ä»ãã®å¯Ÿå¿ããéç¥ã«çœ®ãæããŸãã æåŸã«ããã®ãã¬ãŒã ãåé€ããŸãïŒããŒãžã®ã¯ãªãŒã³ãã®ããïŒã 以äžã®å®è£
ã®è©³çŽ°ãåç
§ããŠãã ããã
æåŸã«ã
SVGãã©ã°ã€ã³ã¯ã€ã³ã¹ããŒã«ãããŠãããJScriptãç¡å¹ã«ãªã£ãŠãã
IEãã©ãŠã¶ãŒãç ç²ã«ããå Žåãåã€ã¡ãŒãžã®å Žæã§éããã¶ã€ã³ãåãé€ãããšãã§ããŸãã ç§ã¯åŒ·ãç ç²ã«ããåŸåããããŸãã 誰ãããã®ãã©ãŠã¶ãèŠæ Œã«æºæ ããããã«æŸèæãå¿
èŠãšããããšãç¥ã£ãŠããã®ã§ã人ããã®äžã®ã¹ã¯ãªãããç¡å¹ã«ãããšã圌ã¯æé»ã®ãã¡ã«ã€ã³ã¿ãŒãããããæ¡ä»¶ä»ãã§ãèŠãããšã«åæããŸãã
ããªãã¯ç°¡åã«æžãããšãã§ããŸãïŒ
<object type="image/svg+xml" data="hello.svg"></object>
ãã ããã¡ã¢ãªã®ããã«èª°ãã«äžèšã®ãªãã·ã§ã³ãé«äŸ¡ãªå Žåããããè¡ãããšãã§ããŸãïŒ
<object type="image/svg+xml" data="hello.svg"> <a href="http://www.adobe.com/svg/viewer/install/">SVG viewer</a>.</object>
次ã«ã
IEã®å Žåã
SVGãã©ã°ã€ã³ãã€ã³ã¹ããŒã«ãããŠããå Žåã¯
object
èŠçŽ ã
embed
èŠçŽ ã«ããŸã ã€ã³ã¹ããŒã«ãããŠããªãå Žåã¯ãªã³ã¯ä»ãã®éç¥ã§çœ®ãæããå¿
èŠããã
object
ã
ãã§ã«ç€ºããããã«ãããŒãžã®ããããŒã«æ¬¡ã®ããã«èšè¿°ããŸãã
<script type="text/ecmascript" src="fixSVG.js"></script>
fixSVG.js
ãã¡ã€ã«ã¯æ¬¡ã®ããã«
fixSVG.js
ãŸãïŒã¹ã¯ãªããã®æ¡ä»¶ä»ãã³ã¡ã³ããæ¢ã«äœ¿çšããŠããŸãïŒã
/*@cc_on if(@_jscript_version<9) window.attachEvent( "onload", function(){ var iframe=document.createElement("iframe"); iframe.src="js/fixSVG_IE_5-8.html"; document.body.appendChild(iframe); } ); @*/
åçã«äœæããããããŒãã£ã³ã°ãã¬ãŒã ã«ããŒãããã
fixSVG_IE_5-8.html
ã®ã³ã³ãã³ãïŒ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Fix SVG for IE 5-8</title> <script type="text/jscript" src="svgcheck.js"></script> <script type="text/vbscript" src="svgcheck.vbs"></script> <script type="text/jscript" src="checkSVGViewer.js"></script> </head> <body></body> </html>
ã¹ã¯ãªãã
svgcheck.js
ããã³
svgcheck.vbs
ã¯çŽ æŽããããæä»ããã§ãã
fixSVG_IE_5-8.js
ã¯æ¬¡ã®ãã®ã§ãã
checkAndGetSVGViewer();// SVG- if(window.svgInstalled){ var objects=window.parent.document.getElementsByTagName("object"); for(var objectNumber=objects.length, objectNode, objectTypeAttr, embedNode, codebase, attrNumber, attrNode; objectNumber--;){ objectNode=objects[objectNumber]; objectTypeAttr=objectNode.attributes["type"]; if(objectTypeAttr=="image/svg+xml" || objectTypeAttr.value=="image/svg+xml"){ embedNode=window.parent.document.createElement("embed"); embedNode.setAttribute("type", "image/svg-xml"); embedNode.setAttribute("pluginspage", "http://www.adobe.com/svg/viewer/install/"); embedNode.setAttribute("wmode", "transparent");// codebase=objectNode.getAttribute("codebase"); embedNode.setAttribute("src", ((null===codebase)?"":codebase)+objectNode.getAttribute("data")); for(attrNumber=objectNode.attributes.length; attrNumber--;){ attrNode=objectNode.attributes[attrNumber]; if(//! IE indexOf! attrNode.name!="archive" && attrNode.name!="classid" && attrNode.name!="codebase" && attrNode.name!="codetype" && attrNode.name!="data" && attrNode.name!="declare" && attrNode.name!="standby" && attrNode.name!="tabindex" && attrNode.name!="type" && attrNode.name!="usemap" ) embedNode.setAttribute(attrNode.name, attrNode.value); } objectNode.parentNode.replaceChild(embedNode, objectNode); } } } else if(window.svgViewerAvailable){// ( , IE 5-8 !) var message; switch(navigator.browserLanguage.substr(0,2)){ case "ru": message=" "; break; case "en": default: message="To view this page you need an"; } var objects=window.parent.document.getElementsByTagName("object"); for(var objectNumber=objects.length, objectTypeAttr; objectNumber--;){ objectTypeAttr=objects[objectNumber].attributes["type"];//objects[objectNumber].getAttribute("type")===null! if(objectTypeAttr=="image/svg+xml" || objectTypeAttr.value=="image/svg+xml")// IE5 objects[objectNumber].outerHTML="<p>"+message+" <a href=\""+getSVGInstallPage()+"\">SVG viewer</a>.</p>"; } } window.frameElement.parentNode.removeChild(window.frameElement);// ,
Webkitãã©ãŠã¶ãŒã®SVGã°ã©ãã£ãã¯ã¹
ãã ããGoogle ChromeãšSafariã«ã¯2ã€ã®åé¡ããããŸãã ãŸããäžè¬çãªã±ãŒã¹ã§ã¯ã
SVGç»åã®æ¯äŸã¹ã±ãŒãªã³ã°ã¯æäŸããŸããã ããã®4çªç®ã®ããŒãžã§ã³ã§ã¯ã
svg
èŠçŽ ã«
width
å±æ§ãš
height
å±æ§ãèšå®ããå¿
èŠãããã5çªç®ã®ããŒãžã§ã³ã§ã¯ãéã«5çªç®ã®ããŒãžã§ã³ãèšå®ãããŠããŸããã§ããïŒ ããã§ããã¹ã±ãŒãªã³ã°ã¯å®å
šã«æºè¶³ã§ãããã®ã§ã¯ãããŸããã
2çªç®ã®åé¡ã¯ããæ·±å»ã§ãã
object
ä»ããŠæ¿å
¥ãããSVGç»å
object
éæãªèæ¯ãæã€å Žåãçœã§å¡ãã€ã¶ãããŸãïŒããã¯
ãã°ã§ãïŒããã«ã2幎以äžåã«éåžžã«å€ãããããã®ãã©ãŠã¶ãŒã®5ã€ã®ããŒãžã§ã³ã§ã¯ä¿®æ£ãããŠããŸããïŒïŒãã ããããã§ã
transparent
å€ãæã€
wmode
å±æ§ã
embed
èŠçŽ ã«è¿œå ããã ãã§ãã
object
ã§ã¯ãªã
img
ã䜿çšããå Žåã¯ãã¹ãŠåé¡ãããŸããããFirefoxã¯
SVGç»åãæ¿å
¥ãããã®æ¹æ³ãç解ããŸããã ãããã£ãŠãåè¿°ã®
fixSVG.js
ãã¡ã€ã«ã«Webkitãã©ãŠã¶ãŒçšã®ã¹ã¯ãªããïŒç¡å¹ãªJavascriptã®ç°åžžãªç¶æ³ã§ã¯çœãèæ¯ã«èŸä»»ïŒãæžã蟌ã¿ãèªã¿èŸŒãŸããããã¥ã¡ã³ãã®SVGç»åã§
object
ã
img
ã«çœ®ãæããŸãã
if(/AppleWebKit/.test(navigator.userAgent)) window.addEventListener( "load", function(){ var objects=document.getElementsByTagName("object"); for(var objectNumber=objects.length, objectNode, codebase, imageNode, attrNumber, attrNode; objectNumber--;){ objectNode=objects[objectNumber]; if(objectNode.getAttribute("type")==="image/svg+xml"){ imageNode=document.createElement("img"); codebase=objectNode.getAttribute("codebase"); imageNode.setAttribute("src", ((null===codebase)?"":codebase)+objectNode.getAttribute("data")); imageNode.setAttribute("alt", "SVG");// alt HTML for(attrNumber=objectNode.attributes.length; attrNumber--;){ attrNode=objectNode.attributes[attrNumber]; if(-1===["declare", "classid", "codebase", "data", "type", "codetype", "archive", "standby", "tabindex"].indexOf(attrNode.name)) imageNode.setAttribute(attrNode.name, attrNode.value); } objectNode.parentNode.replaceChild(imageNode, objectNode); } } }, false );
æ®å¿µãªãããã¹ã¯ãªããã¯ãã®æ¹æ³ã§æ¿å
¥ãããç»åã®åŠçãåæ¢ããããã解決çã¯æ®éçã§ã¯ãããŸããïŒ
è¡ãã FirefoxãOperaããããŠæããã«
IE 9ã«ã¯ãSafariãšGoogle ChromeïŒãã€ãã©ããã§ïŒ
img
ã
IE 5-8-
embed
object
èŠçŽ ãååšããããšããã¹ã¿ã€ãªã³ã°ãšã¹ã¯ãªããäœææã«èŠããŠããŸãã
åã蟌ã¿SVGã€ã¡ãŒãžã®ã¹ã¯ãªããäœæ
é«åºŠãªãã©ãŠã¶ã§ã¯ã
SVGããã¥ã¡ã³ããã
HTMLããã¥ã¡ã³ãã«ã¢ã¯ã»ã¹ããã®ã¯ç°¡åã§ãã
load
ã€ãã³ãã«ãã£ãŠã
object
èŠçŽ ã䜿çšå¯èœã«ãªãã
load
ã€ãã³ããããã«æããããšãã§ããŸãããã®ãã³ãã©ãŒã§ã
object
èŠçŽ ãçŽ æŽãããååŸããŸãã jQueryã䜿çšãããšã次ã®ãããªããšãã§ããŸãã
$( function(){ $("object#SceletonObject").load( function(){ var SVGDocument=$(this)[0].getSVGDocument(); ⊠} ); } );
Internet Explorerã§åé¡ãçºçããŸãã ããŒãžãèªã¿èŸŒãã åŸã
embed
èŠçŽ ãååŸã§ããŸãããŸãã
SVGããã¥ã¡ã³ãã§ããæ¢ã«å©çšå¯èœã§ããããããåé¡ã§ãïŒ -圌ã¯å®å
šã«ç©ºã§ãã
embed
èŠçŽ ã§
load
ã€ãã³ãã
embed
ã§ããŸããã§ããã ããã¯ãŸã£ãããµããŒããããŠããªãããã§ãïŒãã ããç§ãè©Šãã
ãµããŒãã®
ã¯ãã®ã€ãã³ããæ©èœããŸããïŒã
ããã«ãå¥ã®ããªãã¯ãå€æããŸãã
embed
ã
embed
ãªã©ã®èŠçŽ ã®ã³ã³ãã³ãã¯ãå¥ã®ã¹ããªãŒã ã«
éåæã§
ããŒããããŸãã ããã¯ãç§ãç解ããŠããããã«ãäžæ¹ã§ãã¡ã€ã³ããŒãžã®è§£æãå®äºãããŸã§ãèŠçŽ ã¯ã€ãã³ããã³ãã©ãŒãã¢ã¿ããããããã«ãŸã ã¢ã¯ã»ã¹ã§ãããçµäºãããšãèŠçŽ ã®èªã¿èŸŒã¿ã€ãã³ããæ¢ã«æ©èœããå¯èœæ§ãããããã³ãã©ãŒããã³ã°ãããããšã¯ãã¯ãæçšã§ã¯ãªãããšãæå³ããŸãã ç§ãå®éšã§å®æçã«èŠ³å¯ããæåŸã®ã±ãŒã¹ã§ãã°ãªããã®ãã¿ãŒã³ããã£ããããªãã£ãããã§ãã
ã¡ãªã¿ã«ã
ä»æ§ã«ãããšã
object
èŠçŽ ã®
load
ã€ãã³ãã¯ãã
ãŸãã-HTMLã«ã¯
body
èŠçŽ ã®ã¿ããã
ãŸã ã ãããã£ãŠãäžè¬ã«ã©ããã§æ©èœãããšããäºå®ã¯ééã£ãŠããŸãïŒ
次ã®è§£æ±ºçãèŠã€ãããŸããïŒããŸããšã¬ã¬ã³ãã§ã¯ãããŸããã... ...ãŸã èããŠããŸãïŒïŒïŒ
load
ã€ãã³ãã¯
svg
èŠçŽ ã®
SVGã³ãŒãå
ã«èšè¿°ããããããã
HTMLããã¥ã¡ã³ãã®é¢æ°ãåŒã³åºã
ãŸã ã ãã®ãããªãã®ïŒ
<svg xmlns="http://www.w3.org/2000/svg" onload="InitSVG(document);">
ãŸãããŸãã¯ãã¹ãŠã®ãã©ãŠã¶ã§åäžã«åäœããããã«ïŒ
<svg xmlns="http://www.w3.org/2000/svg" onload="if('InitSVG' in window) InitSVG(document); else parent.InitSVG(document);">
ãŸãã¯åçŽã«ïŒãããã¬ãã«ãŠã£ã³ããŠã®
parent
ããã®ãŠã£ã³ããŠèªäœãæãããïŒïŒ
<svg xmlns="http://www.w3.org/2000/svg" onload="parent.InitSVG(document);">
InitSVG
é¢æ°
InitSVG
ã¯ã
SVGããã¥ã¡ã³ããååŸãããããããã¹ãŠã®èŠçŽ ãååŸã§ããŸãã ã¬ãã¿ïŒ
jQueryã䜿çšããŠ
SVGèŠçŽ ãæäœããããšã¯ã§ããªãããšã«çæããŠãã ããïŒäœããã®åé¿çããããããããŸããããç§ã¯ãŸã ãããæãåºãããçºæãããããããšãã§ãããå人çã«ã¯ãã®ã²ãŒã ã¯ããããã®äŸ¡å€ããªããšæããŸããïŒã å®éããã®é¢æ°ã¯
getElementsByTagName
ã¡ãœãããã
HTMLCollection
ã¿ã€ãã®çµæãååŸããããšãæ³å®ããŠãããããéåžžã®é
åã®ããã«ãã€ã³ããã¯ã¹ã«ãã£ãŠèŠçŽ ãéžæã§ããŸãã ãããŠãããã§ïŒFirefoxãé€ããã¹ãŠã®å Žæã§ïŒ
NodeList
åã®
NodeList
ãååŸããŸãããã®çµæãããç¹å¥ãª
item( )
ã¡ãœããã䜿çšããŠã®ã¿èŠçŽ ãããã¯ã§ããŸãã ãã¬ãŒã ã¯ãŒã¯ã¯ããã«é Œããã«äžæããŸãïŒãããã«ãããç§ããããè©Šãããšãã¯ç§ã«ãã®ããã§ããïŒã ãããã£ãŠãã¯ãã¹ãã©ãŠã¶ã念é ã«çœ®ããŠã
DOMã¡ãœãããçŽæ¥æäœããå¿
èŠããããŸãã ããã¯ç·åŒµããŠããŸãããå¯èœã§ãã
SVGããã¥ã¡ã³ãã®ã¹ã¯ãªããã«é¢ãã2ã€ã®ãã©ã€ããŒããªèŠ³å¯ã ãŸããã¹ã¯ãªããã§æå®ãããã¹ã¿ã€ã«ãå€æŽã§ããªãããšãããããŸããã ãã¹ãŠã®ãã€ããã¯ã¹ã¯å±æ§ãä»ããŠå®è£
ããå¿
èŠããããŸãïŒãã¡ããã
fill
è²ãªã©ã®èšèšã«é¢ããŠã¯ããŸãæ£ç¢ºã§ã¯ãããŸããïŒã 第äºã«ã
SVGèŠçŽ ã«å¡ãã€ã¶ãããªãå Žåã
mouseover
ããã³
mouseout
ã¯ãã¬ãŒã äžã§ã®ã¿çºçããåäœããæéããŸã£ãããªãå ŽåããããŸãïŒæ®å¿µãªããã芪èŠçŽ ã§äžåºŠ
fill
å±æ§ãç»é²ã§ããç¶æ¿ãããŸãïŒã
ã»ãã¥ãªãã£äžã®åé¡ã®ããã€ããåå
㧠ããã®æ¹æ³ãChrome 5.0
ã§ããŒã«ã«ã«æ©èœããªããªã£ãã®ã¯é¢çœãããšã§ãã æ¢ã«ç€ºããããã«ãWebkitãã©ãŠã¶ãŒã§
img
ã¿ã°ã䜿çšãããšãŸã£ããæ©èœããªãããšã¯ãŸã£ããé¢çœããããŸããã
SVGZãµãŒããŒããæäŸããæ¹æ³
gzipå§çž®ãè¡ãã«ã¯ã
SVGã°ã©ãã£ãã¯ã¹ããå§ãããŸãã ãã®ãšããããã¡ã€ã«ãµã€ãºã¯3ã4åå°ãããªããŸãã ç§ã®ãããªèª°ããã³ãã³ãã©ã€ã³ããèµ·åããã
gzipãŠãŒãã£ãªãã£ãæ°ã«ããããªãå Žåã圌ã¯å£ããç¡æã§äœ¿çšã§ããŸãããã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ãŒã¹
7-Zipã¢ãŒã«ã€ããåããŠããŸãïŒã¢ãŒã«ã€ãèšå®ã§ã¯ãå¿
ãGzipã¡ãœãããéžæããŠãã ããïŒïŒ
ã¢ãŒã«ã€ããäœæããæ¡åŒµåãèªåçã«
.svg.gz
ãã
.svgz
ã«
.svg.gz
ã
.svgz
ããã®åŸãOperaãšInternet Explorerã®ã¿ãçµæã®ãã¡ã€ã«ãé©åã«èªèããFirefoxãSafariãChromeã
XMLæ§æãèªã£ãŠéŒ»ãåããŠããããšã«é©ããŸããã ãã¡ããã解åãããŸã§ã¯ã©ã®ãããª
XMLã§ããïŒ ãããŠããªãã圌ãã¯è§£åããªãã®ã§ããïŒ
Apacheã®ããã ãšå€æã ãããŸã§ïŒããŒãžã§ã³2.2.12ïŒãããã©ã«ãèšå®ã§ã¯ã
SVG圢åŒã«å¿
èŠãª
Content-Type: image/svg+xml
ããããŒããã©ãŠã¶ãŒã«éä¿¡ããŸããã
Content-Encoding: gzip
ããŒã¹ã®ããŒãžã§ã³ã«ã¯äžèŠãª
Content-Encoding: gzip
ããããŒã
éä¿¡ããŸãã ãããã£ãŠããµãŒããŒæ§æã§ä¿®æ£ãããã.htaccessãã¡ã€ã«ã«ã
AddEncoding gzip .svgz
ããšããè¡ãæžã蟌ãã ãã§ãã
ãŸããïŒFirefoxã®ããã«ïŒä»¥äžãè¿œå ããã¢ããã€ã¹ããããŸããã
<FilesMatch \.svgz$> <IfModule mod_gzip.c> mod_gzip_on No </IfModule> </FilesMatch>
ããããããµãŒããŒããäžãããããã¡ã€ã«ãèªåçã«
gzipããããã«æ§æãããŠããå Žåãããã¯çã«ããªã£ãŠããŸãã ç¥ããŸãã
æè¿ãç§ã¯ãã®åé¡ã«ã€ããŠãããããå°»ãæ±ããŸããããããã¯1ãæéç¶ããŸããã ç§ãç解ããŠããããã«ãApacheã®åã«nginxããã³ããšã³ãããã³ããšã³ãããããããã¯äœããã®åœ¢ã§Apacheãã£ã¬ã¯ãã£ãã䜿çšããèœåãå¶éããŸãã ããå
·äœçã«ã¯ã
AddType
ãã£ã¬ã¯ãã£ãã¯æ©èœããŸããã
AddEncoding
ã¯æ©èœããŸããã ãã¡ããããããã€ããŒã®Webãµã€ãã®ããã«ããã»ã¯ã·ã§ã³ã«ã¯ããã®ãããã³ã°ã«é¢ããèšèããnginxã«ã€ããŠã®èšåã¯å«ãŸããŠããŸããã æè¡ãµããŒãã¯é åºã«ç§ã«è³ãåŸããç§ã®ç§å¯ãäŒããããããŸããã§ãããç§ãçã£ã賌èªè§£é€è
ã«æ±ããŸãããããµãŒããŒã«ã¯å¿
èŠãªãã®ããªãã®ã§ãã¿ã€ãã«ã¯äžããããŸããã
AddEncodingãã£ã¬ã¯ãã£ãApache Mod_gzipã¢ãžã¥ãŒã«ã®åäœ "ã" nginxãå§çž®ãæ
åœããæ®ãã®Apacheãã£ã¬ã¯ãã£ãã¯å®å
šã«ãµããŒããããŠããŸãïŒ "æ¬åœã§ã¯ãªã"ïŒããWeã³ç³ãäžããŸãã æ®å¿µãªããã䜿çšããŠãããµãŒãã¹ã®ãµãŒããŒã§ã¯å©çšã§ããªãmod_deflateã¢ãžã¥ãŒã«ãããå Žåã«ã®ã¿ãsvgz圢åŒã転éã§ããŸããïŒãããŠã5åã®é«äŸ¡ãªãã©ã³ã賌å
¥ããææ¡ã§ãïŒïŒã æçµçã«ã圌ãã¯ç§ã«åŒçšãäœã§ãããã説æããŸããã§ãããã圌ãã¯ãããããŠæ£ããã¿ã€ãã«ãèªåã§äžãå§ããŸããã