Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Contributor
Posts: 3
Registered: ‎06-26-2012
My Device: Bold 9000
My Carrier: Telecom NZ

InnerHTML not working on BlackBerry Bold 9000

Hi,

 

My client has asked me to support his Blackberry devices on their ASP.NET MVC web site. They kindly provided a BlackBerry Bold 9000 (platform 5) to test with. After grabbing jqlite.1.1.2.js and fixing somebugs I found a problem. To illustrate the problem in the simplest fashion I created a test page.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Test</title>

    <script language="javascript" type="text/javascript">
    //<![CDATA[
        window.onload = function () {
            var testDiv = document.getElementById('test');
            testDiv.innerHTML = 'No jQuery here!';
        }
    //]]>
    </script>
</head>
<body>
    <div>
        <p>Test Page using no jQuery</p>
    </div>
    <div id="test">
        Empty Div
    </div>
</body>
</html>

 

The text "Empty Div" is not replaced as I expect. I have tried using various methods to work around this including parsing a string using the DOM parser, insserting it into a new element and using both appendChild and replaceChild to insert the new element. The page content remains stubbornly blank. Curiously, if I construct a simple structure using createElement I can get something to work.

Does this problem sound familiar to anyone? Is there some setting that I have forgotten?

Thanks in advance for any assistance.

 

Andrew.

Developer
Posts: 410
Registered: ‎06-03-2010
My Device: Z10 Red
My Carrier: Free

Re: InnerHTML not working on BlackBerry Bold 9000

I test on a 9000 under OS5 without such problem.

 

  1. Try to put the code inside try/catch to retrieve an error code
  2. Try to put an alert inside you onload, maybe it is not fired.
  3. Try to put your code inside a timeout. In OS5 it seems that the rendering of the HTML is not entirely  finished when onload is called, because I see a big graphic blink
Regular Contributor
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780
My Carrier: Vodafone

Re: InnerHTML not working on BlackBerry Bold 9000

<head runat="server">

Why is this needed if its ran on the device?


//<![CDATA[
//]]>
I dont think thats required either
New Contributor
Posts: 3
Registered: ‎06-26-2012
My Device: Bold 9000
My Carrier: Telecom NZ

Re: InnerHTML not working on BlackBerry Bold 9000

Whoops - this is an ASP.NET MVC application - I grabbed the page source. That markup is chopped out when the page is rendered then streamed to the device.

New Contributor
Posts: 3
Registered: ‎06-26-2012
My Device: Bold 9000
My Carrier: Telecom NZ

Re: InnerHTML not working on BlackBerry Bold 9000

Thanks for your suggestion.

 

I tried with no success - strange.

 

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Test</title>

    <script language="javascript" type="text/javascript">
    //<![CDATA[
        window.onload = function () {
            // See if waiting for a whole second helps
            setTimeout(function () {
                try {
                    var testDiv = document.getElementById('test');
                    testDiv.innerHTML = 'old style is best';
                } catch (e) {
                    alert('caught'+e.Message);
                }
                alert('timer fired');
            }, 1000);

            //$(document).ready(function () {
            //$("#test").html('Not empty any more');
            //});
        }
    //]]>
    </script>
</head>
<body>
    <div>
        <p>Test Page using no jQuery</p>
    </div>
    <div id="test">
        Empty Div
    </div>
</body>
</html>

The alert box "Timer Fired" shows but the content of the test div remains unchanged. Any other ideas?

 

Thanks,

 

 

Andrew.