Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27238] Android: Allow "onlink" property to be set for first time after creating WebView

GitHub Issuen/a
TypeImprovement
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2019-10-03T13:22:26.000+0000
Affected Version/sn/a
Fix Version/sRelease 8.3.0
ComponentsAndroid
LabelsWebView, android, callback, link, parity
ReporterJoshua Quick
AssigneeYordan Banev
Created2019-07-11T23:02:09.000+0000
Updated2019-10-03T13:22:26.000+0000

Description

*Summary:* On Android, the WebView "onlink" callback property currently must be assigned upon creation in order for it to work. It cannot be set after creation. (However, the "onlink" property can be changed after assigned upon creation.) Note that iOS supports setting "onlink" for the 1st time after creation and our API docs do not document it as a creation-only property. We should do this for convenience and parity. https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.WebView-property-onlink *Test case:*

Build and run the below code on Android.

Tap on the WebView's "Show Alert" link.

Notice that a "Webpage not available" appears onscreen.

Build and run on iOS.

Tap on the WebView's "Show Alert" link.

Notice that an alert dialog is displayed. (The "onlink" callback was invoked.)

var htmlText =
		'<!DOCTYPE html>\n' +
		'<html>\n' +
		'	<head>\n' +
		'		<meta name="viewport" content="width=device-width, initial-scale=1.0">\n' +
		'	</head>\n' +
		'	<body>\n' +
		'		<p>WebView "onlink" Test</p>\n' +
		'		<br/>\n' +
		'		<br/>\n' +
		'		<a href="mylink://show/alert">Show Alert</a>\n' +
		'	</body>\n' +
		'</html>\n';

function onLinkHandler(e) {
	if (e.url === "mylink://show/alert") {
		alert("'onlink' callback invoked.");
		return false;
	}
	return true;
}

var window = Ti.UI.createWindow();
var webView = Ti.UI.createWebView({
	html: htmlText,
//	onlink: onLinkHandler,  // <- Must be set upon creation to work.
});
webView.onlink = onLinkHandler;
window.add(webView);
window.open();

Comments

  1. Yordan Banev 2019-08-26

    PR: https://github.com/appcelerator/titanium_mobile/pull/11176
  2. Samir Mohammed 2019-09-24

    FR passed, Waiting on Jenkins build.
  3. Christopher Williams 2019-10-02

    merged to master
  4. Ebenezer Boateng 2019-10-03

    Improvement verified in SDK version 8.3.0.v20191002165629

JSON Source