检查System.Gadget.Flyout.file的值(Checking the value of System.Gadget.Flyout.file)

编程入门 行业动态 更新时间:2024-10-27 08:31:52
检查System.Gadget.Flyout.file的值(Checking the value of System.Gadget.Flyout.file)

我一直在研究Windows SideBar Gadget,其中有多个弹出页面。 当我去显示一个时,我想检查它是否已经激活,所以我想我可以检查System.Gadget.Flyout.file的值。 但是,当我按下导致此弹出窗口弹出的按钮控件时,小工具的背景将消失。 在我的调试消息中,我发现脚本停止了这一行的位置。

这是有问题的一行:

if (!System.Gadget.Flyout.show && System.Gadget.Flyout.file != "results.html") { .... }

这很奇怪,因为我可以设置文件但不检查它。 在MSDN文档中,file属性既是getter又是setter,所以应该没有问题。 任何人都有一个解决方案我可以用来检查当前活动的文件/文件是什么?

编辑 - 以下是代码的详细介绍:

function ShowResults(event) { var searchString = $.trim($("#searchInput").val()); if (!System.Gadget.Flyout.show || !gFlyoutResultsAreVisible) { // Load up the results page into the flyout System.Gadget.Flyout.file = "results.html"; System.Gadget.Flyout.show = true; System.Gadget.Flyout.document.parentWindow.attachEvent("onload", function() { System.Gadget.Flyout.document.parentWindow.PerformSearch(searchString); }); } }

I've been working on a Windows SideBar Gadget wherein I have multiple flyout pages. When I go to display one, I want to check if it is already active or not, so I thought I could just check the value of System.Gadget.Flyout.file. However, when I press the button control that causes this flyout to pop out, the background of the gadget disappears. In my debug messages, I've found that the script halts where this line is.

Here is the line in question:

if (!System.Gadget.Flyout.show && System.Gadget.Flyout.file != "results.html") { .... }

This is quite odd, as I can set the file but not check it. And looking at the MSDN documentation the file property is both a getter and a setter, so there should be no problem. Anyone have a solution I could use to check what file/document is currently active?

Edit - Here is a more detailed look at the code:

function ShowResults(event) { var searchString = $.trim($("#searchInput").val()); if (!System.Gadget.Flyout.show || !gFlyoutResultsAreVisible) { // Load up the results page into the flyout System.Gadget.Flyout.file = "results.html"; System.Gadget.Flyout.show = true; System.Gadget.Flyout.document.parentWindow.attachEvent("onload", function() { System.Gadget.Flyout.document.parentWindow.PerformSearch(searchString); }); } }

最满意答案

这段代码不太可能导致问题。 不过,您可以尝试以下内容:

if (System.Gadget.Flyout.document && System.Gadget.Flyout.file != "results.html") { .... }

如果这没有帮助,你还没有设法自己排序,请发布一些代码,以便我更好地了解正在发生的事情。

更新

啊,我现在看到了。 对不起,当我添加原始答案时,我应该对此进一步测试。 我假设System.Gadget.Flyout.file是一个读/写属性,但当然这只会有太多意义。 System.Gadget.Flyout的文件属性实际上是只写的

作为一种解决方法,我会使用以下内容:

var FlyDoc = System.Gadget.Flyout.document; if (FlyDoc && FlyDoc.location == "x-gadget:///results.html") { ... }

可能我在2006年遇到了这个错误,因为我之前已经编写了上面的代码,所以请原谅我完全忘记了这个问题,而不是在我最初试图回答这个问题时发布正确的解决方案:)

It's unlikely that piece of code is causing the issue. Still, you could try something like the following:

if (System.Gadget.Flyout.document && System.Gadget.Flyout.file != "results.html") { .... }

If that doesn't help and you haven't managed to sort it yourself yet, please post a little more code so I can get a better understanding what's going on.

UPDATED

Ahh I see now. Sorry, I should have tested this further when I added my original answer. I assumed System.Gadget.Flyout.file was a read/write property, but of course that would only make too much sense. The file property of System.Gadget.Flyout is actually write only.

As a workaround, I would use the following:

var FlyDoc = System.Gadget.Flyout.document; if (FlyDoc && FlyDoc.location == "x-gadget:///results.html") { ... }

It's likely that I ran into this bug in 2006, as I've written the above code before, so please forgive me for completely forgetting about this issue and not posting the correct solution when I originally attempted to answer this question :)

更多推荐

本文发布于:2023-08-07 06:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1462918.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Gadget   System   Flyout   Checking   file

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!