我想检测 Google Chrome 信息亭模式。我正在使用此代码来检测信息亭模式。
chrome.app.runtime.onLaunched.addListener(function (launchData) {
alert("chrome");
launchData.isKioskSession; //true or false
});
我收到此错误。
未捕获类型错误:无法读取未定义的属性“onLaunched”
我需要添加一些引用吗?
最佳答案
https://developer.chrome.com/apps/app_lifecycle#launch_data
它说:
Depending on how your app is launched, you may need to handle launch data in your event page. By default, there is no launch data when the app is started by the app launcher. For apps that have file handlers, you need to handle the launchData.items parameter to allow them to be launched with files.
我相信您需要首先检查 launchData 对象是否存在。
chrome.app.runtime.onLaunched.addListener(function (launchData) {
alert("chrome");
if(typeof launchData !== 'undefined') {
// Perform actions with launchData
launchData.isKioskSession; //true or false
}
});
关于javascript - 在 Kiosk 模式下无法读取未定义的属性 'onLaunched',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27857506/