我可以在没有代码的情况下创建兼容浏览器的Silverlight页面吗?

时间:2022-12-04 08:15:50

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).

我一直在使用xaml,javascript和html开发一个silverlight页面(我实际上只有.html,.js和.xaml文件)。问题是,我刚刚意识到它不能在任何浏览器中工作,除了Internet Explorer(肯定是7)。

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.

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

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.

现在,我已经开始使用vb.net或visual c.net创建一个全新的visual studio项目,但xaml文件事件似乎指向事件背后的代码。此外,它将silverlight编译为.XAP文件。 XAP文件实际上是一个带有已编译的dll和appmanifest.xaml的.ZIP文件。

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.

那么,如何配置我的appManifest.xaml来处理只有javascript和xaml的Silverlight页面(以及指向.XAP作为源的html文件)。 html部分,我认为我理解。 AppManifest是一个不同的故事,我肯定需要帮助。

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.

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

1 个解决方案

#1


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

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

http://page*s.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.

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

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.

这证明了使用这种Silverlight模型是可以的,它应该可以在其他浏览器中使用。这也让我去尝试firebug。 Firebug太棒了。如果启用控制台选项卡,则可以确切地看到javascript挂起的位置。现在它正在运行,我可以看到我获取/发布到谷歌应用引擎的结果。

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

Firebug表明我正在使用if else else语句,只有Internet Explorer才允许。例如,

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.

Firefox和Chrome以及safari显然都需要那里不是一个; else和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.

所以,目前,我似乎已经修复了我的跨浏览器兼容性问题,但我仍然想了解更多关于appmanifest.xaml以及如何使用javascript制作.xap文件。我以后可能会需要它。

#1


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

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

http://page*s.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.

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

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.

这证明了使用这种Silverlight模型是可以的,它应该可以在其他浏览器中使用。这也让我去尝试firebug。 Firebug太棒了。如果启用控制台选项卡,则可以确切地看到javascript挂起的位置。现在它正在运行,我可以看到我获取/发布到谷歌应用引擎的结果。

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

Firebug表明我正在使用if else else语句,只有Internet Explorer才允许。例如,

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.

Firefox和Chrome以及safari显然都需要那里不是一个; else和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.

所以,目前,我似乎已经修复了我的跨浏览器兼容性问题,但我仍然想了解更多关于appmanifest.xaml以及如何使用javascript制作.xap文件。我以后可能会需要它。