xsl: document.write() is not working

When document.write is not working at xsl with your browser, setting value to DOM node's innerHTML could be an option.

Here's the simple example of xsl file.

<?xml version="1.0" encoding="ISO-8859-1"?>
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
    <script type="text/javascript">
        document.write("Hello World by document.write");
    <div class="foo" id="foo1"></div>
    <div class="foo" id="foo2"></div>
    <div class="foo" id="foo3"></div>
    <script type="text/javascript">
        foos = document.getElementsByClassName("foo");
        for(i=0; i<foos.length; i++) {
            foos[i].innerHTML = "Hello World by innerHTML";

If you load this xsl with some dummy xml, IE will print out 'Hello World by document.write' only(by lack of 'getElementsByClassName' support) and FF will print out 'Hello World by innerHTML' 3 times.

댓글 없음:

댓글 쓰기