I am hosting a web user control inside the xamWebHtmlViewer and need access to javascript methods that are in page that is run inside the xamWebHtmlViewer. Any ideas on how to access the page hosted within the HtmlViewer?
thanks in advance
Hello-
I did not find a solution for this. I ended up working thru a solution with the HTML content that was being hosted inside the control so I no longer needed the Silverlight Control to talk to the Javascript code.
Good luck.
I know your busy but if you have anything for me on this can you please fire off a quick note. If I can't get this resolved with the XamWebHtmlViewer then I have to look into other methods. I have researched and tried everything I can think of so I must be misunderstanding something here.
Thanks so much,
Lisa
I've also tried replacing
Dim Viewer As FrameworkElement = sender.FindName("MyHTMLViewer1")
with
Dim Viewer As HtmlElement = Doc.GetElementById("_sl_historyFrame")
Which makes more sense since its referencing the htmlFrameElement.
But still no luck.
Hi Doychin
While waiting for a response I got that far. But I still cannot get the java in page1 to find the java function in page2. Here is some of my code:
VB in code behind configurator.xaml (calls xamwebhtmlviewer):
Private Sub btnBlue_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnBlue.Click Dim Viewer As FrameworkElement = sender.FindName("MyHTMLViewer1") HtmlPage.Window.Invoke("sendParam", New Object() {"myLink", "1", Viewer}) End Sub
Main page (page1):
function sendParam(myLink, val, div) { div(ChangeColor('myLink', 'val')); }
<div id="silverlightControlHost"> <object id="SLC" data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="100%"> <!--[if lte IE 8]> <param name="windowless" value="true"/> <![endif]--> <param name="source" value="ClientBin/Web CRM.xap"/> <param name="onerror" value="onSilverlightError" /> <param name="background" value="black" /> <param name="minRuntimeVersion" value="3.0.40624.0" /> <param name="autoUpgrade" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration: none;"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none; text-align:center;"/> </a> </object><iframe id='_sl_historyFrame' style='height:0;width:0;border:0px;'></iframe> </div>
Java in page2:
function ChangeColor(myLink, val) { document.hendriks.send(myLink, val); }
Java error:
Error: ChangeColor is not definedSource File: http://localhost:57096/Web%20CRMSite/#/Views/Configurator.xaml
Thanks for your help.
Lisa.
Lets assume that your main page that contains your silverlight application is called page1. When you add the HtmlViewer to your SL application and set SourceUri, an IFRAME html element is automatically added into your page1. The IFRAME will contain your second page - page2 that contains your Java Applet. From your Silverlight application you can invoke -
HtmlPage
.Window.Invoke(JS_FUNCTION_NAME, new object[] { parameter})
Your java script function should be in page1. The java scrip function will find the IFRAME and access the page2. After that it will access the applet and set the new parameters to it.
Regards,
Doychin Dochev