Overview
Webbrowser.NavigatetostringMethod
Displays the specified HTML content.
TextThe parameters should be set to HTML format.TextParameters can also contain JavaScript. If HTML contains JavaScript Functions, you can useInvokescriptFrom the managedCodeCall this type of function. Do not useNavigatetostringDisplays untrusted HTML content.
Effect:
XAML code:
< Grid X: Name = "Layoutroot" >
< Grid. Background >
< Lineargradientbrush Startpoint = "0, 0" Endpoint = "0, 1" >
< Gradientstop Color = "# Ff0055dd" Offset = "0" />
< Gradientstop Color = "# Ff00ddff" Offset = "1" />
</ Lineargradientbrush >
</ Grid. Background >
< Webbrowser X: Name = "Web" Margin = "15" />
</ Grid >
CS code:
Public Mainpage ()
{
Initializecomponent ();
Loaded + = New Routedeventhandler (mainpage_loaded );
}
Void Mainpage_loaded ( Object Sender, routedeventargs E)
{
// Use stringbuilder to create an HTML content page
VaR html = New Stringbuilder ();
Html. append ( " <HTML> " );
Html. append ( " <HTML> " );
Html. append ( " <Body style = 'font-family: Arial; font-size: 20pt '> " );
Html. append ( " <Div style = 'color: Blue '> " );
Html. append ( " This is the first Div " );
Html. append ( " </Div> " );
Html. append ( " <Div style = 'color: Orange '> " );
Html. append ( " This is the second Div. " );
Html. append ( " </Div> " );
Html. append ( " <HTML> " );
Html. append ( " </Body> " );
// Webbrowser. navigatetostring Method
// Displays the specified HTML content.
// The text parameter should be set to HTML format. The text parameter can also contain JavaScript.
// If HTML contains JavaScript Functions, you can use the invokescript method to call these functions from managed code.
// For security reasons, it is best not to use navigatetostring to display untrusted HTML content.
Web. navigatetostring (html. tostring ());
}
Success !!!
Source code download
author: memories of lost youth
Source: http://www.cnblogs.com/lukun/
copyright of this Article It is shared by the author and the blog site. You are welcome to repost it, but this statement must be kept without the author's consent, and in the Article page obvious position to give the original connection, if there is a problem, you can contact me through the http://www.cnblogs.com/lukun/ , thank you very much.