Jump to content

Embedded IE fails to load webpage


Recommended Posts

Hello everyone,

I encountered this strange issue while working on a freelance project, I cannot give you the webpage/website on which this is happening because it is an internal site which is inaccessible externally. I am attempting to create a GUI with an IE control embedded in it, but when I navigate to the desired address, it shows a blank white page.

The webpage does load if I use a different browser or normal (non-embedded) IE instance.

I managed to get my hands on the source of the blank page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

    <head>
        <link rel="stylesheet" type="text/css" href="res://ieframe.dll/ErrorPageTemplate.css" />

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

        <title>Navigationen blev annulleret</title>

        <script src="res://ieframe.dll/errorPageStrings.js" language="javascript" type="text/javascript">
        </script>
        <script src="res://ieframe.dll/httpErrorPagesScripts.js" language="javascript" type="text/javascript">
        </script>
    </head>

    <body onLoad="javascript:navCancelInit(); ">

        <table width="730" cellpadding="0" cellspacing="0" border="0">

        <!-- Error title -->
            <tr>
                <td id="infoIconAlign" width="60" align="left" valign="top" rowspan="2">
                    <img src="res://ieframe.dll/info_48.png" id="infoIcon" alt="Oplysningsikon">
                </td>
                <td id="mainTitleAlign" valign="middle" align="left" width="*">
                    <h1 id="mainTitle">Navigationen til websiden blev annulleret</h1>
                </td>
            </tr>



            <tr>
                <!-- This row is for HTTP status code, as well as the divider-->
                <td id="errorCodeAlign" class="errorCodeAndDivider" align="right">&nbsp;
                    <div class="divider"></div>
                </td>
            </tr>


        <!-- Error Body -->

        <!-- What you can do -->
            <tr>
                <td>
                    &nbsp;
                </td>
                <td id="whatToTryAlign" valign="top" align="left">
                    <h2 id="whatToTry">Prøv at:</h2>
                </td>
            </tr>

        <!-- refresh page -->
            <tr>
                <td >
                    &nbsp;
                </td>
                <td id="refreshPageAlign" align="left" valign="middle">
                    <h4>
                        <table>
                          <tr>
                              <td valign="top">
                                  <img src="res://ieframe.dll/bullet.png" border="0" alt="" class="actionIcon">
                              </td>
                              <td valign="top">
                                  <span id="navCancelContainer"></span><noscript id="refreshPage">Opdatere siden.</noscript>
                              </td>
                          </tr>
                        </table>
                    </h4>
                </td>
            </tr>
        </table>
    </body>
</html>

The ieframe.dll resources are a point of interest. I am not sure how the server is able to detect the embedded instance of IE :unsure:...

Any suggestions? Here is a basic outline of the script:

#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Main()

While True
    Sleep(1000)
WEnd

Func Main()
    ; Create GUI
    $hGUI = GUICreate("", $GUI_WIDTH, $GUI_HEIGHT, $iLeft, $iTop, $WS_POPUP)
    $oIE = _IECreateEmbedded()
    ;$oIE = _IECreate() ; This works, but it is not embedded in the GUI
    GUICtrlCreateObj($oIE, 0, 0, $GUI_WIDTH, $GUI_HEIGHT)
    GUISetState()

    ; Navigate to the URL and authenticate
    _IENavigate($oIE, $URL)
EndFunc

Thank you for the advice in advance!

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

On 5/2/2019 at 3:04 PM, FrancescoDiMuro said:

In the Help file it is stated to set the style $WS_CLIPCHILDREN to the GUI, since there may be visualization issue without that style.

It did indeed help! Instead of the white blank page it did show an error when I added the style: "Navigation was cancelled" (or something along those lines).

What really fixed the issue was navigating to about:blank before performing any other actions (including navigation), so the working code looks a bit like this:

#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Main()

While True
    Sleep(1000)
WEnd

Func Main()
    ; Create GUI
    $hGUI = GUICreate("", $GUI_WIDTH, $GUI_HEIGHT, $iLeft, $iTop, $WS_POPUP + $WS_CLIPCHILDREN)
    $oIE = _IECreateEmbedded()
    ;$oIE = _IECreate() ; This works, but it is not embedded in the GUI
    GUICtrlCreateObj($oIE, 0, 0, $GUI_WIDTH, $GUI_HEIGHT)
    GUISetState()

    ; Initialize by navigating to about:blank
    _IENavigate($oIE, 'about:blank')

    ; Navigate to the URL and authenticate
    _IENavigate($oIE, $URL)
EndFunc

Navigating to about:blank was indeed mentioned in the helpfile, but it only stated that we "must therefore use _IENavigate() to navigate this browser to 'about:blank' after it has been embedded into the parent application and before you attempt any operations that rely on having a document loaded (e.g. _IEBodyWriteHTML())". I did notice it initially when I was writing code, but I decided to navigate directly to the URL since I did not have to perform any operations relying on having a document loaded... now guess other operations are effected too :think:

 

On 5/2/2019 at 6:22 PM, Danp2 said:

Could the issue be the result of the embedded browser version using a very old version of IE? I vaguely recall a thread where you can adjust this, but you'll need to locate it on your own. 😉

Not really sure about that as I am pretty sure only one version of IE is present in an installation of Windows. Thanks for the tip but I have fixed my issue by navigating to about:blank first :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

11 minutes ago, TheDcoder said:

I did notice it initially when I was writing code, but I decided to navigate directly to the URL since I did not have to perform any operations relying on having a document loaded... now guess other operations are effected too :think:

Exactly!
It doesn't seem to affect any other "action" less the automatic navigation to the about:blank; by the way, happy to have helped (even if a little bit) :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...