2015-01-09 41 views
1

我想检测谷歌Chrome信息亭模式“onLaunched”的定义。我正在使用此代码来检测信息亭模式。无法读取性能在Kiosk模式

chrome.app.runtime.onLaunched.addListener(function (launchData) { 

      alert("chrome"); 
      launchData.isKioskSession; //true or false 
     }); 

我得到这个错误。

遗漏的类型错误:未定义

无法读取属性“onLaunched”我需要补充一些参考?

回答

0

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 
    } 
}); 
+0

我没有得到它的属性 – dvirus

+0

在文档中说,当应用程序启动应用程序启动器时,您的事件侦听器将无法获取launchData对象。 “未捕获类型错误:未定义无法读取属性‘onLaunched’”是指launchData未定义,其是相同的不存在。 – zaynetro

+0

仍然没有working..i试图jQuery的全屏检测code.that也不起作用 – dvirus

0

如果您在Chrome应用中运行,则列出的代码将可用。如果您正在使用--kiosk选项启动的Chrome浏览器中运行,则chrome.app.runtime将不确定。

的--kiosk选项功能上等同于在全屏模式下运行,并且可以使用Fullscreen API来检测。

var fullscreenEnabled = document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled; 

我不知道直接检测--kiosk选项的方法。