我可以创建跨浏览器兼容的 silverlight 页面而无需隐藏代码吗?

发布于 2024-07-27 03:43:05 字数 727 浏览 6 评论 0原文

我一直在开发一个仅使用 xaml、javascript 和 html 的 silverlight 页面(我实际上只有 .html、.js 和 .xaml 文件)。 问题是,我刚刚意识到它无法在除 Internet Explorer(当然是 7)之外的任何浏览器中运行。

我的代码行太多,想要在后面添加 vb.net 或 Visual C 代码并使用 html 桥。 我只想让 xaml 鼠标事件像以前一样直接工作。 换句话说,当xaml的MouseLeftButtonDown说“highlightMe”时,我希望highlightMe函数成为一个javascript函数。 但我也希望我的页面可以在任何浏览器中运行。

现在,我尝试使用 vb.net 或 Visual c.net 创建一个全新的 Visual Studio 项目,但 xaml 文件事件似乎指向事件背后的代码。 此外,它将 silverlight 编译成 .XAP 文件。 XAP 文件实际上是一个 .ZIP 文件,其中包含已编译的 dll 和 appmanifest.xaml。

那么,如何配置我的 appManifest.xaml 来处理仅包含 javascript 和 xaml(以及指向 .XAP 作为源的 html 文件)的 silverlight 页面。 html部分,我想我明白了。 AppManifest 是另一回事,我绝对需要这方面的帮助。

我认为这与创建 app.xaml 和 page.xaml 以及使用主标记的 x:Class 值有关。

I have been developing a silverlight page using just xaml, javascript and html (I literally only have a .html, .js and .xaml file). The problem is, I just realized that it isn't working in any browser EXCEPT Internet Explorer (7 for sure).

I have too many lines of code to want to add vb.net or visual c code behind and use the html bridge. I just want the xaml mouse events to work directly as before. In other words, when the xaml's MouseLeftButtonDown says "highlightMe" I want that highlightMe function to be a javascript function. But I also want my page to work in any browser.

Now, I've played around with creating a brand new visual studio project with vb.net or visual c.net but the xaml file events seem to point to code behind events. Also, it compiles the silverlight into a .XAP file. The XAP file is actually a .ZIP file with a compiled dll and an appmanifest.xaml.

So, how do I configure my appManifest.xaml to handle a silverlight page that has only javascript and xaml (and an html file pointing to the .XAP as the source). The html part, I THINK I understand. AppManifest is a different story and I definitely need help with that one.

I think it has something to do with creating an app.xaml and page.xaml and using the x:Class value of the main tag.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅黛梨妆こ 2024-08-03 03:43:05

自从我问这个问题以来,我发现了一个页面...

http://pagebrooks.com/archive/2009/02/19/custom-loading-screens-in-silverlight.aspx

...1) 向人们展示了最近使用类似模型的 .js.xaml.html 为他们的 silverlight 页面,2) 评论中有人建议使用 firebug 来跟踪 silverlight javascript 错误的问题。

这向我证明了使用这种 silverlight 模型是可以的,并且它应该可以在其他浏览器中工作。 这也让我去尝试firebug。 Firebug 太棒了。 如果启用控制台选项卡,您可以准确地看到 javascript 挂起的位置。 现在它可以工作了,我可以看到我的 gets/posts 到 google 应用引擎的结果。

Firebug 表明我正在以只有 Internet Explorer 允许的方式使用 if then else 语句。 例如,它

if (blah == 1) { blah2 = 3}

else { blah2 = 5};

适用于所有浏览器,但事实并非如此:

if (blah == 1) { blah2 = 3} ;

else { blah2 = 5};

Firefox 和 chrome 以及 safari 显然都不需要 ; else 和 if 之间的结束语句字符。

因此,目前,我似乎已经解决了跨浏览器兼容性问题,但我仍然想了解更多有关 appmanifest.xaml 以及如何制作 .xap<仅包含 javascript 的 /code> 文件。 我稍后可能需要它。

Since I asked this question I found a page...

http://pagebrooks.com/archive/2009/02/19/custom-loading-screens-in-silverlight.aspx

...that 1) showed people recently using a similar model of .js, .xaml and .html for their silverlight page and 2) someone in the comments recommended using firebug to track down issues with silverlight javascript errors.

This proved to me it's ok to use this model of silverlight and that it should work in other browsers. This also made me go try firebug. Firebug is AWESOME. If you enable the console tab, you can see exactly where the javascript was hanging up. And now that it's working, I can see the result of my gets/posts to google app engine.

Firebug showed that I was using if then else statements in a way that only internet explorer allows. For example,

if (blah == 1) { blah2 = 3}

else { blah2 = 5};

works in every browser, but this doesn't:

if (blah == 1) { blah2 = 3} ;

else { blah2 = 5};

Firefox and chrome and safari all apparently need there to NOT be a ; end statement character between the else and if.

So, for the moment, I appear to have fixed my problem with cross-browser compatibility, but I'd still like to know more about appmanifest.xaml and how to make a .xap file with only javascript. I might need it later.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文