css - error adding xml-style sheet to an SVG object inside javascript -
I get an error when I add this line of code to my JavaScript file,
Parse error : Syntax error, unexpected T_STRING
var data = "& lt ;? xml-stylesheet type = 'text / css' href = 'css / main.css'? & Gt;" + "& Lt; svg xmlns = 'http: //www.w3.org/2000/svg' width = '800' height = '800' & gt;" + "& lt; foreign object width = '100%' Height = '100%' & gt; "+" & lt; div xmlns = 'http: //www.w3.org/1999/xhtml'> " + $ ("#mainbody"). HTML () + "& lt; / div & gt; & lt; / foreign object & gt; & lt; / svg & gt;"; When I delete this part:
"xml-stylesheet type = 'text / css' href =' css / main CSS '? & Gt; However, I have the same line in the second file, but there is no problem
What could be the problem?
This is a PHP error, do you have & lt;? or ? & Gt; Sequences need to be avoided, which has special meaning for PHP However, even after fixing it and after making PHP happy, If you try to set the "html" property of some DOM nodes in this data variable that you are defining, you get a different error. Which is saying that the DOM string is bad (or possibly, code> & lt ;? xml-stylesheet? & Gt; pseudo-instruction will be ignored). That's because xml-stylesheet is something that comes in the beginning of any XML document , not an element Html property when an SVG Documents is displayed, it does not appear within an HTML page on the SVG piece. What are you trying to achieve here? There are CSS announcements in the main.css file that are specifically for that piece of SVG? Why is not the CSS file included in the header of the HTML file? Another possible solution is to separate SVG into a separate file, and it involves using an IMG element or something - in that case & lt ;? Xml-stylesheet? & Gt; The pseudo-instruction will work just fine but it will not allow you to do what you think you are trying to do with the object $ ("# mainbody") - Which is ... what? Somehow do HTML wrap in SVG? Why?
Comments
Post a Comment