Announcement

Collapse
No announcement yet.

Embedded Browser - Show Source

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Embedded Browser - Show Source

    I can put a custom context menu in a browser but do not know how to implement Show Source.

    From what I've read, the use of "view-source:" in front of the URL, as shown in the code below, is supposed to work but it does not seem to work for me!

    Code:
    Sub TestCode
       Local WB As IWebBrowser2
       Local vVar As Variant
    '   vVar = "view-source:file:///" + Exe.Path$ + "temp\tempthread.htm"    'fails
    '   vVar = "view-source:http://www.garybeene.com/"                        'fails
       vVar = "http://www.garybeene.com/"                                    'just a normal URL, works fine
       WB = OC_GetDispatch(hBrowser)
       WB.Navigate2(vVar)
    End Sub

  • #2
    This particular need is for gbThreads. In this case, where I have access to the URL as a local file, I can simply open the local file in NotePad.

    But, I'd rather view the raw file content within the browser, as View Source presents it.



    Comment


    • #3
      I think you are SOOL. For e, it works in FF and Chrome, , but not in IE

      Click image for larger version  Name:	CantDisplay.jpg Views:	1 Size:	12.0 KB ID:	792499I

      Comment


      • #4
        Stuart, thanks for checking that. in the other browsers.

        Bummer. I'm standing on the corner empty-handed. If IE doesn't support it, I can't fix that

        Another thought I had is to create a temp file, where the HTML content I want to see is bounded the PRE tags. Unfortunately the HTML stuff inside still shows. Perhaps a little more experimentation will get that to work - show the entire file content without the browser interpreting it for display.

        Short term, the use of a popup NotePad works. I just don't like the popup.

        Comment


        • #5
          Hey,
          You could create an hidden textbox that is superposed to the browser and swap from one to the other...
          You may even split them and show both...

          Comment


          • #6
            Originally posted by Gary Beene View Post
            Stuart, thanks for checking that. in the other browsers.

            Bummer. I'm standing on the corner empty-handed. If IE doesn't support it, I can't fix that

            Another thought I had is to create a temp file, where the HTML content I want to see is bounded the PRE tags. Unfortunately the HTML stuff inside still shows. Perhaps a little more experimentation will get that to work - show the entire file content without the browser interpreting it for display.

            Short term, the use of a popup NotePad works. I just don't like the popup.
            Just tried "View Source in the IE on my WIn7 laptop. It pops up the source in a new window which looks a lot like a stripped down Notepad.

            Comment


            • #7
              Howdy, Stuart!

              So, it works on Win7 but not WIn10?


              And Howdy, Pierre!
              Yep, that would avoid the look of a popup. I'll have to think about that. The NotePad popup solution is awfully simple and I've added that to gbThreads but I don't want to settle for that permanently.

              I'd have thought I could display the content of an HTML file in the browser as plain text, without the browser using it to format the display. The <pre></pre> tags covering the entire content did not work.

              But I' swear that some years ago I made that work, or have seen it work. I'll let it brew in my brain and hopefully something will pop out!

              Also, I'll do a search on "display as plain text" and see what I can found.

              Comment


              • #8
                Success!

                The "plain text" was the key to the search. First thing I found was this approach ...

                <plaintext> ... </plaintext>

                I tested it in gbThreads and it appears to work. The embedded browser appears to support those tags.

                Click image for larger version

Name:	pb_2209.jpg
Views:	89
Size:	93.8 KB
ID:	792529

                Comment


                • #9
                  Originally posted by Gary Beene View Post
                  Howdy, Stuart!

                  So, it works on Win7 but not WIn10?
                  No "viewsource:URL" doesn't work.

                  Right clicking on the IE windows presents a menu with View Source as an item. Selecting it opens a dialog with a very simple menu and what is probably a RichText control displaying the source text.

                  Comment


                  • #10
                    Howdy, Stuart!

                    In the next release of gbThreads, I'll replace the default context menu with one of my own. "View Source" will be there and it will use the code that allowed me to demonstrate the image in post #8. The source code will be displayed directly in the embedded browser.

                    Comment


                    • #11
                      Originally posted by Gary Beene View Post
                      Success!

                      The "plain text" was the key to the search. First thing I found was this approach ...

                      <plaintext> ... </plaintext>

                      I tested it in gbThreads and it appears to work. The embedded browser appears to support those tags.
                      <plaintext> does not have a closing tag.

                      </plaintext> is pointless since <plaintext> renders everything following it as plain text. The browser engine will never recognise a </plaintext> tag

                      It's also worth bearing in mind that <plaintext> is depreciated /obsolete and may not work if the embedded browser is updated.

                      https://developer.mozilla.org/en-US/...ment/plaintext

                      Obsolete
                      This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

                      The HTML Plaintext Element (<plaintext>) renders everything following the start tag as raw text, ignoring any following HTML. There is no closing tag, since everything after it is considered raw text.

                      Note: Do not use this element.
                      • <plaintext> is deprecated since HTML 2, and not all browsers implemented it. Browsers that did implement it didn't do so consistently.
                      • <plaintext> is obsolete in HTML5; browsers that accept it may instead treat it as a <pre> element that still interprets HTML within.
                      • If <plaintext> is the first element on the page (other than any non-displayed elements, like <head>), do not use HTML at all. Instead serve a text file with the text/plain MIME-type.
                      • Instead of <plaintext>, use the <pre> element or, if semantically accurate (such as for inline text), the <code> element. Escape any <, > and & characters, to prevent browsers inadvertently parsing content the element content as HTML.
                      • A monospaced font can be applied to any HTML element via a CSS font-family style with the monospace generic value.

                      Added: It was actually OBSOLETE'd in 1995
                      https://www.w3.org/MarkUp/1995-archive/NonStandard.html

                      Comment


                      • #12
                        Howdy, Stuart!

                        Yep, I discovered that the </plaintext> simply appeared in the display and had to remove it.


                        I assume that IE is left in Windows for legacy reasons and I'd guess there will be no updates ever. I'm more worried that they'll take it out completely.

                        If they do update it, there may be more of my apps, those that use the embedded browser, that take a hit. But if one of my apps does take a hit, I plan to be alive to fix it!

                        Or, if I'm not alive, as the saying goes, "That is a problem, just not my problem to solve!"

                        Comment

                        Working...
                        X