Can Silverlight initiate Page Refreshes?

前端 未结 5 2174
-上瘾入骨i
-上瘾入骨i 2020-12-06 00:14

UPDATE: An alternative title for this could be: How do I call javascript from my silverlight 2.0 application.

Here is a quick question for all you Silverlight gurus.

5条回答
  •  清歌不尽
    2020-12-06 01:10

    Just a quick note on why HtmlPage.Window.Invoke("location.reload(true);"); doesn't work: it appears from my quick testing that the way Silverlight implements Invoke is to look up a property with the given name on the specified JavaScript object and call it. So this code would say, "Find a property on the window object named 'location.reload(true);' and call it with zero arguments." There is, instead, a GetProperty method that will let you get the window's location property and invoke reload on that with the parameter true. The final code looks like this:

    ((ScriptObject)HtmlPage.Window.GetProperty("location")).Invoke("reload", true);

提交回复
热议问题