Note that there are some explanatory texts on larger screens.

plurals
  1. POFirefox not running jQuery for XHTML output
    text
    copied!<p>Okay, I did a crappy job of describing the issue in my previous post. I think the discussion got sidetracked from the core issue - so I'm going to try again. <em><a href="http://en.wiktionary.org/wiki/mea_culpa" rel="nofollow noreferrer">Mea Culpa</a></em> to <strong>Elzo Valugi</strong> about the aforementioned thread.</p> <p>I have an XML file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;?xml-stylesheet type="text/xsl" href="wtf.xsl"?&gt; &lt;Paragraphs&gt; &lt;Paragraph&gt;Hi&lt;/Paragraph&gt; &lt;/Paragraphs&gt; </code></pre> <p>Simple enough. I also have a stylesheet to create XHTML output:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" indent="yes" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" omit-xml-declaration="yes"/&gt; &lt;xsl:template match="/*"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;title&gt;FF-JS-XHTML WTF&lt;/title&gt; &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="wtf.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;xsl:apply-templates /&gt; &lt;/body&gt; &lt;/html&gt; &lt;/xsl:template&gt; &lt;xsl:template match="Paragraph"&gt; &lt;p&gt; &lt;xsl:apply-templates /&gt; &lt;/p&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Last but not least, I have the following jQuery <em><a href="http://en.wiktionary.org/wiki/in_toto" rel="nofollow noreferrer">in toto</a></em> (wtf.js, from the script tag in the stylesheet):</p> <pre><code>$(function() { alert('Hiya!'); $('&lt;p&gt;Hello&lt;/p&gt;').appendTo('body'); }); </code></pre> <p>Extremely simple, but sufficient for the demonstration. When I run this in Internet Explorer, I get the alert 'Hiya!' as well as the expected:</p> <pre><code>Hi Hello </code></pre> <p>but when I run it in Firefox (3.0.1), I still get the alert, but the jQuery does not insert the paragraph into the DOM, and I just get this:</p> <pre><code>Hi </code></pre> <p>If I change the stylesheet to <strong>method="html"</strong> it works fine, and I get (along with the alert):</p> <pre><code>Hi Hello </code></pre> <p>Why doesn't Firefox run the jQuery with an XHTML document? Has anyone any experience with this problem?</p> <h1>EDIT: ADDITIONAL INFO</h1> <p>I can successfully insert elements into the documents this way in Firefox (method="xml"):</p> <pre><code>var frag = document.createDocumentFragment(); var p = document.createElement('p'); p.appendChild(document.createTextNode('Ipsum Lorem')); frag.appendChild(p); $('body').append(frag); </code></pre> <p>but I'm running into a similar problem with the <strong>.remove()</strong> method.</p> <p>It is looking more and more that Firefox doesn't construct a DOM from XML that jQuery can relate to, or somesuch.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload