在silverlight的应用中,我们需要嵌入html页面。
我们可以使用RadHtmlPlaceholder 控件在应用中嵌入页面:
<telerik:RadHtmlPlaceholder HorizontalAlignment="Left" Height="800"
SourceUrl="http://localhost:8088/test.html"
x:Name="frameTask" Visibility="Visible" />
如果我们需要调用test.html的脚本如何操作呢?
下面是我研究出来的交互代码:
我test.html页面写了testAlert的脚本。
HtmlElement el = frameTask.HtmlPresenter;
HtmlWindow window=(HtmlWindow)el.Children[0].GetProperty("contentWindow");
ScriptObject script = window.GetProperty("testAlert") as ScriptObject;
script.InvokeSelf();
通过这样的代码就可以和内嵌页面进行交互了。