top

document.body [null] error

Published 2014-10-27 | (Compatible with SDK 3.5,4.5,5.0,5.1 and 2012,2013,2014 models)

Troubleshooting document.body errors on 2012 devices

Sometimes on launching widget, blank screen is displayed as javaScript is included in <head></head>. When document.body is used, webkit develops error since still <body> has not appeared. In Maple, error doesn’t develop because <body> always exists.

Source Files

Note

The files needed for the sample application are here.

Solution

Move the body related scripts from head tag section to body tag section.

Bad example

<head>
    <script>
        document.body.appendChild(domNode);
    </script>
</head>
<body>
</body>

Good example

<head>
</head>
<body>
    <script>
        document.body.appendChild(domNode);
    </script>
</body>

See also

This situation occurs also if the IME module is included in the document head. See How to implement correctly the IME module? for more details.