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: 178
Registered: ‎07-29-2008
My Device: Not Specified

Webworks inside an iframe

I am working on a javascript app for the playbook using webworks, and because of how it all fits together, I would like to run webworks code inside an iframe.

 

The issue is that it seems that when I execute code inside the iframe "blackberry" doesn't exist.  Is there a way to pass this down to iframe?

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Webworks inside an iframe

Yes, this is a known issue that is being worked on

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Developer
Posts: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: Webworks inside an iframe

Tim,

 

Thanks alot for your answer.

 

Is this something that will be fixed by launch?  If i am working on something that depends on this, should I hold off on submission until after the next beta drop of webworks?  Or if it is a minor side note to my project, should I submit and hope it magicly starts working?

 

I poked around at the generated action script, but I'm not sure the right aproach or even if it is possible to do from the flash level.

 

Let me know,

 

thanks again tim,

 

Matt

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Webworks inside an iframe

Hi Matt,

 

It doesn't look like the fix is going to be in the Version 1 RTM.. it will be in a follow up version of the PlayBook OS.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Developer
Posts: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: Webworks inside an iframe

Tim,

 

   Thanks, Can you confirm that this is a Browser or API issue, and not something that I could potentially work around via the WebWorks Opensource? 

 

Matt

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Webworks inside an iframe

Hi Matt,

 

It is an issue in the core WebView API on the PlayBook that doesn't allow us a chance to inject JavaScript APIs into an iframe.  

 

It won't be something that could be corrected in the open source code.. it is a core web view issue.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 29
Registered: ‎06-17-2010
My Device: Bold 9700
My Carrier: Wind

Re: Webworks inside an iframe

Any update on this?

Developer
Posts: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: Webworks inside an iframe

If your iframe is populated by Local Code, you should be able to create an iframe shiv in javascript.  If i ever get off my butt and make one I will post it to github.  

 

Basicly you need to call evail on the iframes window object and you can pass references between them.  

 

You can call evail on an iframe in webworks (because my JSConsole port depends on it) but I am not certain if webwork's partial disregard for same origin extends far enough to do this for all iframes ie ones that violate same origin,

Contributor
Posts: 29
Registered: ‎06-17-2010
My Device: Bold 9700
My Carrier: Wind

Re: Webworks inside an iframe

If you have an example/snippet I'd love to see it.

All I'm doing in my case is, I have an html file which contains javascript to pull an ad via OpenX.

When the user clicks on the ad it should invoke the pb browser. Right now it does not allow that to happen even though the src of the iframe is local, and compiled within my app as a seperate html file. Ad.html in this case.
Highlighted
Developer
Posts: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: Webworks inside an iframe

This should work in my experience.

 

            var ifrm = $('iframe')[0];
            ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? 
ifrm.contentDocument.document : ifrm.contentDocument; ifrm.eval('shiv = {Navigate : function(url){}};'); var shiv = ifrm.eval('shiv'); shiv.Navigate = function (url){ blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER,
new blackberry.invoke.BrowserArguments(url);); };

 though you don't need jquery there if you made the iframe to begin with.