javascript - XSLT loaded with AJAX, contains <script> fired only in Firefox -


i write application ajax loads xslt has <script> inside.

the strange thing script runs in firefox without eval(). script not ran in opera or chrome. so, simplify code , post here.

is firefox bug?

is there cross-browser workaround? (a workaround not run eval() on firefox, scripts xslt, run eval() on chrome, opera every script loaded ajax - both in xslt or in xhtml).

index.xhtml

<?xml version="1.0" encoding="utf-8"?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head><script src="app.js" /></head> <body onload="locationhashchanged();" /> </html> 

app.js

function get(file) {     var request = new xmlhttprequest();     request.open("get", file, false);     request.send();     return request.responsexml; }  function insert(where, root) {     //var scripts = root.getelementsbytagname('script');     where.parentnode.replacechild(root, where);     //for(var z = 0; z != scripts.length; z++) eval(scripts[z]); }  function locationhashchanged() {     var xml = get('apps.xml');     var xslt = get('xslt.xsl');     var xsltprocessor = new xsltprocessor();     xsltprocessor.importstylesheet(xslt);     insert(document.body, xsltprocessor.transformtofragment(xml, document).firstchild); }; 

xslt.xsl

<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">  <xsl:strip-space elements="*" />   <xsl:template match="//*[@path='']"> <body xmlns="http://www.w3.org/1999/xhtml"> <script>alert('only in firefox');</script> </body> </xsl:template>  </xsl:stylesheet> 

apps.xml

<?xml version="1.0" encoding="utf-8"?> <menu name="" path="" /> 

would put alert in cdata tag? so

<script type="text/javascript">   <![cdata[alert('only in firefox');]]> </script> 

i've started doing javascript include in xslt templates


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -