{ "id": "63210", "key": "TIMOB-2578", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2012-03-05T10:50:35.000+0000", "created": "2011-04-15T03:23:15.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [], "versions": [ { "id": "11225", "name": "Release 1.5.0", "archived": true, "released": true, "releaseDate": "2010-12-14" } ], "issuelinks": [ { "id": "15528", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "87150", "key": "TIMOB-7849", "fields": { "summary": "iOS: TiUIWebView beforeload event doesn't have the URL ", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-22T20:36:11.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}
When a user click on a link inside the WebView, the received\r\nevent URL property isn't correctly setted.
\r\nCode:
\r\nwebview.addEventListener('beforeload', function(e) {
\r\nTitanium.API.info(e);
\r\n
\r\n});
\r\nOutput:
\r\nsource = \"[object TiUIWebView]\";
\r\ntype = beforeload;
\r\nurl =\r\n\"file://localhost/Users/myuser/Workspace/TitaniumWorkspace/MyApp/Resources/procedureHTML/06_07_2010/11_00.html\";
\r\n}
Context:
\r\nI have a local HTML file with different type of links (towards PDF,\r\nDOC, etc). I have to prevent some default behavior.
Note:
\r\nWhen also registering a \"load\" event, which is called just after,\r\nthe url is correctly configured.
SDK 1.5.0 GA & 1.5.1 nightly
Jeremy
\nWhile this may be a valid bug, you have not have explained this\nticket thoroughly-enough to be useful. Would you follow \nthis guide and fill in the missing information, please?
\nThanks
Please assign and increase priority of this ticket for iOS.
\nAnyone developing web browsing apps is going to eventually need\nthe ability to examine the URL before loading in the web view for\nURL filtering and information pop-ups, etc.
\nHere's a Use Case:
\nIn iOS create a WebView with TouchScreen enabled and it loads\nthe URL defined at WebView creation. User touches the screen on a\nhyperlink and WebView starts to load a malicious or advertising\nsite. The app creator can provide in the app a whitelist of trusted\nURLS (or domains) to prevent loading of such websites and alert the\nuser that the site has been blocked. To do this the url property of\nthe WebView must be updated at the 'beforeload' event or there is\nno way to detect the pending page load.
\nPer your workflow I've posted to the community Q&A for\npotential work arounds.
\nThanks, Chris
In addition, there seems to be no way to prevent the webview\nfrom loading an URL, after inspecting it during the beforeload\nevent.
\nOn iOS, you'd normally use shouldStartLoadWithRequest in the\nwebview proxy to do this. But I see from the code that Appcelerator\nunconditionally returns YES on that method.
\nTo implement the sort of behaviour described in this ticket, I\nthink it's necessary to provide some sort of bridge to that method\n- or to provide an additional API method to abort the current URL,\nusable within the beforeload event. Without that, some important\nfunctionality is crippled compared with native iOS apps.
\nNote that I've tried issuing stopLoading() from within\nbeforeload, but it doesn't work - presumably because the event is\nasynchronous and so can't get to the request in time.
\nI presume there's an equivalent way of doing this on Android,\nbut I haven't looked into it yet.
This would be a huge help. Being able to detect what URL the\nuser is trying to load before it loads is a must for security and\nfor app integration with webview.
\nI for one would like to capture a URL from a share button in\nwebview and preform facebook, twitter etc functions with in the app\nrather than going to the web version of said social site.
\nPlease fix the beforeload event to update the URL, also, being\nable to stop the URL from loading, like cancelLoad() or something\nwould be great too.
\nTHanks, keep up the good work!
Please Fix This!
I agree, getting before-load to work, or better yet a wrapper\naround shouldStartLoadWithRequest would be extremely helpful. Our\ncurrent workaround is to use load and then reload the previous url\nimmediately after performing the required actions, but this is less\nthan ideal for many reasons.
Is there a fix/feature planned? Apologize if I missed a roadmap\ndocument somewhere.
\nI am developing an eCommerce application. I would like to do the\nfollowing on iOS and Android. Currently testing on iOS.
\n\n\nwebview1.addEventListener('beforeload',function(e){\n logger('webview1 beforeload event : webview1.url = ', webview1.url);\n \n // Broken. \n logger('webview1 beforeload event : e.url = ', e.url ); \n \n logger('webview1 stopLoading call', '');\n webview1.stopLoading();\n \n Titanium.UI.createAlertDialog({title:'Alert', message:'Browsing Canceled.'}).show();\n \n logger('webview1 goBack call', ''); \n webview1.goBack();\n});
\n
\n-Jim
I am building a safe browser app for the iPhone and it requires\nvalidating the url before it is loaded. Seems 'beforeload' event\nand being able to call webView.stopLading() if the url is not\nallowed is fundamental in this case.
\nAny idea on when this problems will be fixed?
\nKeep up the great work!
\nDiego
Still not enough information in the ticket to be able to handle\nit.
I found this article, which contains a neat trick that will\nmaybe help in cases where you're in control of the HTML and able to\nconvert elements appropriately:
\n\nhttp://boydlee.com/appcelerator-titanium/capturing-titanium-events-...
\nIt's certainly what I'll be trying to work around this\nproblem.