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

Adobe AIR Development

Reply
Highlighted
Contributor
Posts: 12
Registered: ‎05-12-2011
My Device: Curve 9300
My Carrier: Bell Mobility
Accepted Solution

QNXStageWebView and javascript window.open

So it looks like QNXStageWebView should have good javascript window support. I have the following set up:

 

 

webView.enableJavaScript = true;
webView.blockPopups = false;
webView.zOrder = 0;

 

But window.open event's don't seem to be opening up on their own. It's then that I noticed the OpenWindowEvent class and included:

 

 

webView.addEventListener(OpenWindowEvent.OPEN_WINDOW, handleOpenWindow);
private function handleOpenWindow(event:OpenWindowEvent):void {
	trace(event.url);
	trace(event.name);
}

 

thinking this was how you were supposed to handle the new windows. Unfortunately event.name always returns properly and event.url is ALWAYS blank so I can't even handle the event manually.

Am I missing something? Has anyone had any experience handling javascript windows with the new QNXStageWebView class? I'm pulling my hair out trying to figure out how these are supposed to be handled and there's very little information on this class right now.

 

 

Regular Contributor
Posts: 93
Registered: ‎02-03-2011
My Device: Not Specified

Re: QNXStageWebView and javascript window.open

I had been using it for a while before documentation came out re the znxcallextensionmethod and thought that both .url and .name were returning properly.  Wtihin the Javascript, are you passing strings for both parameters?  

 

If it continues to be blank, here are a few suggests for work arounds:

- append the 'url' string & the 'name' string together with some unique marker in between (eg "::::::") and then pass that string as the .name

- use the qnxcallextensionmethod to tell your flash to open a new window, rather than the openwindow command

 

A bit of info on the above is here:

http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/QNXStageWebView-pass-values-or-ca...

Contributor
Posts: 12
Registered: ‎05-12-2011
My Device: Curve 9300
My Carrier: Bell Mobility

Re: QNXStageWebView and javascript window.open

[ Edited ]

Thanks for the reply. 

 

Unfortunately the end product will have no control over how the javascript code is passed.

 

What I'm trying to do is display an external site that will not display correctly in the default playbook browser due to userAgent limitations. My goal was to use QNXStageWebView to spoof a userAgent that the website deems "compatible" so that it will display. This has all gone fine except the javascript window handling.

 

I know its not a compatibility problem with the website because I created a small test html file on my webserver to rule this out. The code I'm testing against is as simple as you can possibly make a javascript window:

 

 

<input type="button" onclick="javascript&colon;window.open('http://www.google.ca','Google');" value="Click Me">

 

 

When this is loaded into the QNXStageWebView component and the button is clicked the OpenWindowEvent fire's just fine every time but it passes a blank .url value.

 

 

private function handleOpenWindow(event:OpenWindowEvent):void
{
	trace(event.bubbles);
	trace(event.cancelable);
	trace(event.eventPhase);				
	trace(event.action);
	trace(event.url);
	trace(event.name);
	(event.target==null) ? trace("target null") : trace(event.target);
	(event.currentTarget==null) ? trace("cuurentTarget null") : trace("currentTarget set");
	(event.view==null) ? trace("view null") : trace("view set");
}

 Output:

 

 

[SWF] userAgentSpoof.swf - 604,582 bytes after decompression
false
false
2
null

Google
[object QNXStageWebView]
currentTarget set
view null

 

As you can see every value is behaving like it should be EXCEPT the most important .url value. Very very frustrating.

 

 

Regular Contributor
Posts: 93
Registered: ‎02-03-2011
My Device: Not Specified

Re: QNXStageWebView and javascript window.open

I just had a look at the docs here:

http://www.blackberry.com/developers/docs/airapi/1.0.0/qnx/media/QNXStageWebView.html#eventSmiley SurprisedpenWindow

 

It appears that url is in fact capitalized: URL, whereas name is not.  Try that.

 

...Jim

 

Contributor
Posts: 12
Registered: ‎05-12-2011
My Device: Curve 9300
My Carrier: Bell Mobility

Re: QNXStageWebView and javascript window.open

YES! It works! Thank you Jim!!! You are a true hero.

Contributor
Posts: 12
Registered: ‎05-12-2011
My Device: Curve 9300
My Carrier: Bell Mobility

Re: QNXStageWebView and javascript window.open

Except there's still one kind of annoying problem.

webView.loadURL(event.URL);

 

causes a compiler error:

 

 

1119: Access of possibly undefined property URL through a reference with static type qnx.eventsSmiley SurprisedpenWindowEvent. userAgentSpoof.as /userAgentSpoof/src line 129 Flex Problem
Very very annoying. No way around this I'm assuming?