[ https://issues.apache.org/jira/browse/WEEX-330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16465493#comment-16465493 ]
Danz He edited comment on WEEX-330 at 5/7/18 6:48 AM: ------------------------------------------------------ As doumented in [http://weex.apache.org/references/components/web.html#pagefinish], getting title through `event.title` is a 'iOS only' feature. There are some reasons why we haven't supported in web: # In web platform, the 'web' component is actually implemented as a iframe element. As all iframe elements will encounter, a cross origin security problem is a problem we have to solve in user's code. But we shouldn't assume user has done that, right? So to access a content document's title may cause a cross-domain-security error and break the code in runtime. It's not safe to do that. # If you have solved cross domain problem, you can access the title through webview elelement. A example is here: [http://dotwe.org/vue/0a5ad6d508f086c66a6c220d71a8f140] . In 'pageFinish' event handler, we use 'this.$refs.webview.$el' to get the dom element and access the title attribute in its content document. What could be improved: The 'event.title' should be provided when user want to access the content title in 'pagefinish' event. We can assume user have solved the cross domain issue in web and return the content document's title in the event object, or we can catch the error when user haven't solve the problem and provide a empty title without breaking any code logic (I'll add it to my TODO list). BTW, you can post issues in [https://github.com/weexteam/weex-vue-render/issues] this project when you have any problem in web platform when using weex-vue-render. was (Author: danzh): As doumented in [http://weex.apache.org/references/components/web.html#pagefinish], getting title through `event.title` is a 'iOS only' feature. There are some reasons why we haven't supported in web: # In web platform, the 'web' component is actually implemented as a iframe element. As all iframe elements will encounter, a cross origin security problem is a problem we have to solve in user's code. But we should assume user has done that, right? So to access a content document's title may cause a cross-domain-security error and break the code in runtime. It's not safe to do that. # If you have solved cross domain problem, you can access the title through webview elelement. A example is here: [http://dotwe.org/vue/0a5ad6d508f086c66a6c220d71a8f140] . In 'pageFinish' event handler, we use 'this.$refs.webview.$el' to get the dom element and access the title attribute in its content document. What could be improved: The 'event.title' should be provided when user want to access the content title in 'pagefinish' event. We can assume user have solved the cross domain issue in web and return the content document's title in the event object, or we can catch the error when user haven't solve the problem and provide a empty title without breaking any code logic (I'll add it to my TODO list). BTW, you can post issues in [https://github.com/weexteam/weex-vue-render/issues] this project when you have any problem in web platform when using weex-vue-render. > <web> component not updating title on web renderer > -------------------------------------------------- > > Key: WEEX-330 > URL: https://issues.apache.org/jira/browse/WEEX-330 > Project: Weex > Issue Type: Bug > Components: Web Renderer > Affects Versions: 0.12 > Environment: Firefox 59, Ubuntu 17.10 x64, Both dotwe.org and the > weex command line tool v1.3.4 (latest release in npm). It seems to carry out > through several versions. > Reporter: Gonzalo Ruiz > Assignee: Danz He > Priority: Major > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > Cannot read a "web" component's <title> on the web renderer. It works on > Android but the value is simply "" on the web renderer. > I'm using the title tag to pass an auth token from a webview to the app's JS > code to execute a login, but my code only works on a real device, making > development troublesome. > > Link to reproduce the issue: > [http://dotwe.org/vue/0e21b48adcc302ca8c90449e083acf62] > > This is a resource to aid with fixing the issue: a jsFiddle demo that > successfully retrieves the title from an iframe object: > [https://jsfiddle.net/wLvdexkq/] > The only code that needs to be executed is the following: > document.getElementById("main-content-iframe").contentDocument.title > But mind that this needs to be executed when the iframe loads. > > Thanks. -- This message was sent by Atlassian JIRA (v7.6.3#76005)