JavaScript 运行时错误:无法获取未定义或空引用的属性“激活" [英] JavaScript runtime error: Unable to get property 'activate' of undefined or null reference

查看:61
本文介绍了JavaScript 运行时错误:无法获取未定义或空引用的属性“激活"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误:

0x800a138f - JavaScript 运行时错误:无法获取未定义或空引用的属性激活"

0x800a138f - JavaScript runtime error: Unable to get property 'activate' of undefined or null reference

在我的 UWP 应用中运行以下 javascript 行时:

when running the following line of javascript in my UWP App:

Windows.UI.Xaml.Window.activate();
Windows.UI.Xaml.Window.current.activate();

Windows.UI.Core.CoreWindow.activate();

API 参考处理应用激活文档

推荐答案

Windows.Ui.Xaml 和您链接的文档与 HTML/JavaScript 应用程序无关.Windows.UI.Xaml 仅在 Xaml 应用中使用.

Windows.Ui.Xaml and the docs you linked aren't relevant for HTML/JavaScript apps. Windows.UI.Xaml is used only in Xaml apps.

调用 activate 你需要一个 Windows.UI.Core.CoreWindow 对象,但 Windows.UI.Core.CoreWindow 本身在逻辑上是一个类而不是一个对象

To call activate You need a Windows.UI.Core.CoreWindow object, but Windows.UI.Core.CoreWindow itself is logically a class not an object

您需要创建或获取类的实例才能调用 activate.要获得这样的对象调用 CoreWindow 的静态方法 getForCurrentThread

You need to create or acquire an instance of the class to call activate. To get such an object call CoreWindow's static method getForCurrentThread

var window = Windows.UI.Core.CoreWindow.getForCurrentThread();
Window.activate();

也就是说,您实际上想解决什么问题?你为什么叫这个?JavaScript 应用程序中的初始窗口激活由应用程序代码未显式调用的框架代码处理.除非您在应用中管理多个 CoreWindows,否则尝试激活窗口将取决于它是否已处于活动状态:您不能将窗口强加给用户.

That said, what problem are you actually trying to solve? Why are you calling this? Initial window activation in JavaScript apps is handled by framework code not called explicitly by app code. Unless you're managing multiple CoreWindows in your app, attempts to activate the window will depend on it already being active: you can't force your window on the user.

这篇关于JavaScript 运行时错误:无法获取未定义或空引用的属性“激活"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆