[TIMOB-23503] Windows: WebView local script doesn't work for hyperlink
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-06-14T19:18:02.000+0000 |
Affected Version/s | Release 5.4.0 |
Fix Version/s | Release 6.0.0 |
Components | Windows |
Labels | n/a |
Reporter | Kota Iguchi |
Assignee | Kota Iguchi |
Created | 2016-06-13T07:14:37.000+0000 |
Updated | 2016-10-14T16:56:14.000+0000 |
Description
[WebView local script](https://wiki.appcelerator.org/display/guides2/Communication+Between+WebViews+and+Titanium) does work for the first page, but it doesn't work on the next page where you follow its hyperlink.
var win = Ti.UI.createWindow();
var view = Ti.UI.createView({backgroundColor:'blue'});
var webview = Ti.UI.createWebView({
url: 'WebViewTestPage.htm',
height: '80%',
width: Ti.UI.FILL,
bottom: 0
});
var button = Ti.UI.createButton({
title: 'fromTitanium',
height: '10%',
width: Ti.UI.FILL,
top: 0, left: 0
});
button.addEventListener('click', function (e) {
Ti.App.fireEvent('app:fromTitanium', { message: 'event fired from Titanium, handled in WebView' });
});
Ti.App.addEventListener('app:fromWebView', function (e) {
alert(e.message);
});
view.add(webview);
view.add(button);
win.add(view);
win.open();
<html>
<head>
<script>
Ti.App.addEventListener("app:fromTitanium", function(e) {
Ti.API.info(e.message);
});
</script>
</head>
<body>
<h2><a href="ms-appx-web:///NextPage.htm">Follow this link and see if script works</a></h2>
<button onclick="Ti.App.fireEvent('app:fromWebView', { message: 'event fired from WebView, handled in Titanium' });">fromWebView</button>
</body>
</html>
<html>
<head>
<script>
Ti.App.addEventListener("app:fromTitanium", function(e) {
Ti.API.info(e.message);
});
</script>
</head>
<body>
<h2>NextPage.htm</h2>
<button onclick="Ti.App.fireEvent('app:fromWebView', { message: 'event fired from WebView, handled in Titanium' });">fromWebView</button>
</body>
</html>
https://github.com/appcelerator/titanium_mobile_windows/pull/744
Verified using: OS: Microsoft Windows 10 Pro 10.0.14393 Appc core: 6.0.0-58 Appc NPM: 4.2.8-7 Ti SDK: 6.0.0.v20161013072802 Appc Studio: 4.8.0.201610060953 Lumia 550 10.0 Alert dialog is shown as expected in both pages Closing ticket