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
Developer
Posts: 142
Registered: ‎07-27-2011
My Device: Red Z10, 32GB PlayBook, Numerous Android/WP8/FirefoxOS/Other devices
My Carrier: T-Mobile

Javascript to load iframe src from localstorage not working with BBUI

[ Edited ]

Hoping someone can help me with this.

I wrote some html which creates a localstorage string of an html page I want to load in an iframe.I then got this javascript function to have the iframe load whatever localstorage html page is set. 

Here's what the javascript  and iframe code looks like: 

 

<iframe id="myframe" frameborder="0" src="" width="800" height="600"></iframe>

<script language="JavaScript">
    document.getElementById("myframe").src="x-javascript&colon;open(window.location = localStorage.getItem('launchpage'))"; 
</script>

  

The code works just fine when I test it using my apache server. But when I plug it into my BBUI app, it doesn't work.

If I put the javascript into the head of the index.html, the iframe just doesn't load anything. If I put the the javascript into the html page that has the iframe, nothing on the page will load.

I used webinspector and the localstorage key is correct. 

Anyone have any suggestions?

 

-----------------------------------------------------------------------------------------



Developer
Posts: 314
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: Javascript to load iframe src from localstorage not working with BBUI

why are you using a script inside the src attribute? just change src to the html page.
Nuno
Regular Contributor
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780
My Carrier: Vodafone

Re: Javascript to load iframe src from localstorage not working with BBUI

I think it would be better to have the javascript run at head, then dynamicly set the value of the src rather than loading "help.html" then doing some javascript..

Just a thought
Developer
Posts: 142
Registered: ‎07-27-2011
My Device: Red Z10, 32GB PlayBook, Numerous Android/WP8/FirefoxOS/Other devices
My Carrier: T-Mobile

Re: Javascript to load iframe src from localstorage not working with BBUI

Thanks for the help guys, but I want the user to be able to designate what html page is loaded by default when the app launches (help.html was in there by mistake, I edited the OP to remove it). The problem is that the above code works, UNLESS I plug it into a BBUI app.

-----------------------------------------------------------------------------------------