Is it possible to add <style> and <script> to html file contained in .Net WebView control ? How ?

schlebe 21 Reputation points
2020-04-20T17:18:26.173+00:00

I have written following VB.Net code (see below) to display an HTML file containing Unicode characters greater than 0xFFF.

Dim sText As XElement =  
&lt;html&gt;  
    &lt;head&gt;  
        &lt;style type=&#34;text/css&#34;&gt;  
            unicode  
                {  
                background-color: yellow;  
                }  
        &lt;/style&gt;  
    &lt;/head&gt;  
    &lt;body&gt;  
        &lt;script type=&#39;text/javascript&#39;&gt;  
            function clickUnicode()  
                {  
                var sValue = &#34;?&#34;;  
                window.external.notify(sValue);  
                }    
        &lt;/script&gt;  
        &lt;div class=&#34;unicode&#34; onclick=&#34;clickUnicode()&#34;&gt;&#x1F600;&lt;/div&gt;  
        &lt;div class=&#34;unicode&#34; onclick=&#34;clickUnicode()&#34;&gt;&#x1F601;&lt;/div&gt;  
        &lt;div class=&#34;unicode&#34; onclick=&#34;clickUnicode()&#34;&gt;&#x1F602;&lt;/div&gt;  
        &lt;div class=&#34;unicode&#34; onclick=&#34;clickUnicode()&#34;&gt;&#x1F603;&lt;/div&gt;  
        &lt;div class=&#34;unicode&#34; onclick=&#34;clickUnicode()&#34;&gt;&#x1F604;&lt;/div&gt;  
        &lt;div class=&#34;unicode&#34; onclick=&#34;clickUnicode()&#34;&gt;&#x1F605;&lt;/div&gt;  
        &lt;div class=&#34;unicode&#34; onclick=&#34;clickUnicode()&#34;&gt;&#x1F606;&lt;/div&gt;  
        &lt;div class=&#34;unicode&#34; onclick=&#34;clickUnicode()&#34;&gt;&#x1F607;&lt;/div&gt;  
    &lt;/body&gt;  
&lt;/html&gt;]  
wv.Settings.IsScriptNotifyAllowed = True   
wv.Settings.IsJavaScriptEnabled = True  
wv.NavigateToString(sText)  

When I analyse the result (see Image), I see that <script> text and <style> text has been added as TEXT.

7611-captureunicode.png

Normally only emoticons are visible !

Is it possible to add <style> and <script> to html file contained in .Net WebView control ? How ?

If I copy HTML element in an HTML file and I double click on it, I obtain following result on Chrome

7577-capturewebviewonchrome.png

@schlebe

I have put any tag because following tags are not accepted !

VB.Net Javascript CSS WebView WinForm

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,882 questions
0 comments No comments
{count} votes

Accepted answer
  1. Dave Patrick 426K Reputation points MVP
    2020-04-20T17:37:12.66+00:00

    QnA currently supports the products listed in right-hand pane (more to be added) Better to reach out to subject matter experts in dedicated forums over here.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral

    https://forums.asp.net/36.aspx/1?Visual+Basic+NET

    (please don't forget to mark helpful replies as answer)

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. schlebe 21 Reputation points
    2020-04-20T18:10:57.243+00:00

    Yes, but I have tried to put a question on MSDN just before but the system have refused to include the images because I'm not VALIDATED.
    I have also seen a message indicating that MSDN is migrating. So I have followed the link in MSDN to create a post here.

    I'm very disappointed when searching to add some tags. Now I understand why important tags as VB.Net are missing !

    Please, can you make something for me ?

    Can you validate my login so that I can post my question with images on MSDN ?

    I'm new on x.x@Stuff .com because I'm in retirement and that I cannot more have access to my professional email that was x.x@karthik.pallapothu@atos.net .net.

    0 comments No comments

  2. Dave Patrick 426K Reputation points MVP
    2020-04-20T18:22:43.707+00:00

    Many of the MSDN/TechNet forums including the ones I linked have not yet migrated. As to MSDN verification you can expedite verification by replying to this thread with your request.

    https://social.msdn.microsoft.com/Forums/en-US/94f05325-8566-4c4c-806c-179a5a0beafc/verify-accounts-43?forum=reportabug

    Sticky located at top of Forums Issues (not product support) forum

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=reportabug

    0 comments No comments