Silverlight 4 OOB application to access HTML DOM pages in a WebBrowser control

Does anyone know if it is possible to access and manage an element on the html page displayed by the Silverlight 4 WebBrowser control.

The scenario is as follows. The user launches the Silverlight OOB application with increased trust. The user manipulates some data in the application, but must send some of the data to an external website. If I open an external site in the WebBrowser control, can I help the user by pre-filling some information in the web form of external sites through programmatic access to the DOM?

+2
source share
2 answers

Quick answer: None.

Long answer: The initial intention of OOTB + WebBrowserControl was to help customers bake on Rich Text Format displays (Email, RSS, etc.), and at the same time provide the ability to print support for large documents (reports, etc.) .d.).

The same rules apply to the iframe as you have with this control (as far as I know, there are no plans to change this).

, , , , Silverlight - , DOS - ​​.. Silverlight ( , , , ).

- / Silverlight.

+2

javascript WebBrowser InvokeScript. , .

:

Html

<html ><head>
    <script type="text/javascript">
        function SetValues(val) {
            document.getElementById("q").value = val;
        }
    </script>
</head><body>
<input type="text" id="q" />
</body></html>

Xaml

 <Grid x:Name="LayoutRoot" Background="White">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="268*" />
            <ColumnDefinition Width="132*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <WebBrowser Name="webBrowser1" Grid.Row="1" Grid.ColumnSpan="2" />
        <Button Content="Search" Name="button1" Click="button1_Click" 
                Grid.Column="1" />
        <TextBox Name="textBox1" />
    </Grid>

public MainPage()
{
  InitializeComponent();
  webBrowser1.Navigate(new Uri("http://localhost:58976/HTMLPage1.htm"));        
}

private void button1_Click(object sender, RoutedEventArgs e)
{         
  webBrowser1.InvokeScript("SetValues",textBox1.Text);
}
+2

Source: https://habr.com/ru/post/1749532/


All Articles