Question

This works:

<html>
    <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"> </script>
    <script type="text/javascript" src="jqReady.js"> </script>
    </head>

    <body>

    <div id="hello">Empty</div>

    </body>
</html>

this does not work:

<?xml version="1.0" encoding="utf-8" ?>

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"><!-- required for FF3 and Opera --><jsp:text> </jsp:text></script>
    <script type="text/javascript" src="jqReady.js"><!-- required for FF3 and Opera --><jsp:text> </jsp:text></script>
    </head>

    <body>

    <div id="hello">Empty</div>

    </body>
    </html>
</jsp:root>

Both use the same jqReady.js:

$(document).ready(function() {
    $("#hello").text("Hello, world " + new Date());
    $("body").css("background-color", "grey");
});

In case of the function passed to ready() is not called.

Using Firebug I have observed that $.isReady

  • is true in case of
  • but it's false in case of

I am using Iceweasel 3.5.16 (like Firefox 3.5.15), JBoss 7.1.1

Related questions/answers (I have already applied those recommendations):

Was it helpful?

Solution

I have found the solution here: HTML5 JSPX template

Using the template from that page, this JSPX works as expected:

<?xml version="1.0" encoding="utf-8" ?>

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
    <jsp:directive.page contentType="text/html" pageEncoding="utf-8" />
    <jsp:output omit-xml-declaration="true" />
    <jsp:output doctype-root-element="HTML"
        doctype-system="about:legacy-compat" />

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"><!-- required for FF3 and Opera --><jsp:text> </jsp:text></script>
    <script type="text/javascript" src="jqReady.js"><!-- required for FF3 and Opera --><jsp:text> </jsp:text></script>
    </head>

    <body>

    <div id="hello">Empty</div>

    </body>
    </html>
</jsp:root>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top