Javascript callback on blackberry

Posted by Jeff on Stack Overflow See other posts from Stack Overflow or by Jeff
Published on 2010-04-12T14:50:46Z Indexed on 2010/04/12 14:53 UTC
Read the original article Hit count: 347

Filed under:
|
|

I'm working on a mobile project, and I have a script that is dynamically generated on the backend and then appended to the document (the html page). Desktop browsers seem to append the script correctly and call any functions in the script, however, I can't get this to happen on Blackberry phones. I know that the script is being appending because I can alert it after I append it. I just can get it to call the function in the script.

For example, if I have code like this:

var scriptText = document.createElement('script');
scriptText.type = 'text/javascript';
scriptText.id = 'thisScript';
scriptText.innerHTML = 'alert("hello");';
document.getElementById('idName').appendChild(scriptText);

alert(document.getElementById('thisScript')); //Alerts the script element.

This will alert 'hello' in desktop browsers and even the iPhone/iPodTouch, but not BlackBerry's. Anyone have any idea why? Or if there's a fix/hack?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about mobile-phones