alert doesn't work in packaged apps

笑着哭i 提交于 2019-12-13 19:03:41

问题



I'm studying webview in packaged apps of chrome and I'm studying browser sample from chrome. in browser.js file in onload function, I added alert("webview apps"); at the first row and the code didn't work anymore, when I deleted this row, it worked again.

onload = function() {
    alert("webview app");
    var webview = document.querySelector('webview');
    doLayout();
    ...
}


so does alert work on packaged apps?
P/s: console.log also doesn't work, I saw the source code use it, but nothing is displayed on inspect element window


回答1:


Console.log should work, it all depends on what view you are looking at. For example to get to the logs when in a window, you have to "Inspect Element" on the page to get to it.

Alert has been disabled along with confirm and a number of other legacy web features.




回答2:


You can set up your package app to run in a sandboxed mode, but this will not allow access to any of the api's that manipulate the page.

http://developer.chrome.com/apps/sandboxingEval.html

This will essentially allow the app to run in its own environment allowing you to view the app as you have programmed it. This is done for security of creating apps. Console.log works perfect. When you go to inspect element and then select console in the inspect element view you should see any "echo" results you wanted printed.




回答3:


This sounds like debugging. And if you want to debug a packaged app, the Developer Tools should be enough to replace alert (and other dialogs). But the Developer Tools are not enabled by default. You can enable it on the chrome://flags/#debug-packed-apps.

Check this out this blog post for an example.



来源:https://stackoverflow.com/questions/13798706/alert-doesnt-work-in-packaged-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!