Copy link to clipboard
Copied
Hi all,
I'm developing an AIR app for iOS using CS6 AIR 3.9. I have a textfield that loads in dynamic content from an external xml file and links (anchor tags) will sometimes be in the content. Now when the user taps on a hyperlink, i want StageWebView to open and load the URL . That does happen but what also happens is the native browser opens too, forcing the app to the background and the browser launches the same webpage.
I think i've narrowed down the problem to the fact that the anchor tag is being used, the default behviour would be to open the webpage in the browser on mouse click.
My question is how do i stop the anchor tag from launching the native browser so the user will always stay in the app? I thought about using e.preventDefault() but i'm not sure where to place it in the code or if it would work because i'm not using any functions to open the broswer in the first place.
I've copied the function that executes when the user taps the textfield.
var webView:StageWebView;
var swvRect:Rectangle;
var swvHeight:Number;
var swvY:Number;
var linkURL:String;
myTextField.addEventListener(MouseEvent.MOUSE_UP, linkClicked);
function linkClicked(e:MouseEvent😞void {
var idx:int = e.target.getCharIndexAtPoint(e.localX, e.localY);
trace("Tapped:",idx);
var tf:TextFormat = e.target.getTextFormat(idx);
if(tf.url != "" && tf.url != null) {
linkURL = tf.url;
trace(linkURL);
if(webView!=null){
return;
}
webView=new StageWebView();
webView.stage=this.stage;
webView.viewPort=new Rectangle(0,swvY,stage.stageWidth,swvHeight);
webView.addEventListener(ErrorEvent.ERROR,onError);
webView.addEventListener(LocationChangeEvent.LOCATION_CHANGING,onChanging);
webView.addEventListener(Event.COMPLETE,onComplete);
webView.loadURL(linkURL);
}
}
Any and all help is appricieated
Regards
Daniel
Copy link to clipboard
Copied
This forum is for comments about the forums themselves. There are two main AIR fora. I am not sure which you will need:
http://forums.adobe.com/community/air/problems?view=discussions
http://forums.adobe.com/community/air/development?view=discussions
--OB