Results 1 to 10 of 10

Thread: possible to force IE onto a form?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    possible to force IE onto a form?

    hello, I am dealing with a web login, that once logged in via internet explorer, javascript after authentication closes the parent login window and creates a new internet explorer window (it terminates the login window, and shows you a new window, disconnected from client error on original ie instance). I am able to use the code below to identify the window and determine which window I need to address after the window close occurs:

    Code:
    For Each ie As SHDocVw.InternetExplorer In shellWindows
    
    'test for correct window here
    Next

    It is pretty annoying trying to handle that Javascript. Essentially, I want to control the browser on a form, exactly like a web browser control. The problem I have found while trying to use the web browser control, is it is forced to close and I have not been able to handle the new window event correctly. I tried passing a cookie back to the web browser control, perhaps incorrectly, and re-navigating to the intranet url. Suffice to say it did not work:

    Code:
    'ie as object = internetexplorer window
     htmldoc = ie.Document
      getcookie = htmldoc.cookie
    
    'then later
    
    webbrowsercontrol1.document.cookie = getcookie
    webbrowsercontrol1.navigate(intraneturl)
    Things I have thought of and have tried so far:
    - WebBrowserControl - keeping the popup in the same window. It crashes after javascript tries to close/format the control
    - Unsuccessfully pass a cookie back from IE to the web browser control, then renav the control
    - Handle New Window Event (Crashes once the JS runs)

    However, by identifying the IE window containing the URL of the page I want, I can set that window to be an object then control it that way- but its not as fancy as having it as a web browser control. I would have to have a form seperate from the IE instance, say, using mshtml form side to control the browser. My other idea is to handle the hwnd of that window and force it on my form. Any suggestions for the right direction? Thanks..
    Last edited by jayinthe813; Mar 7th, 2013 at 09:30 PM.

  2. #2
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    Re: possible to force IE onto a form?

    HI, are you able to see the javascript that does this? if so you could just rewrite it in the ie.Document (it has to be apart of the document) so no pop up happens.

    However without source code I can only speculate
    My CodeBank Submissions
    • Listbox with transparency and picture support - Click Here
    • Check for a true internet connection - Click Here
    • Open Cash drawer connected to receipt printer - Click Here
    • Custom color and size border around form - Click Here
    • Upload file to website without user logins, includes PHP - Click Here
    • List All Removable USB Storage Devices - Click Here
    • Custom On/Off Slide Control - Click Here
    • Insert multiple rows of data into one database table using parameters - Click Here
    • Trigger USB/Serial Cash Drawer - Click Here

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: possible to force IE onto a form?

    Right, and I now dont have the source. I am going to try to trap the document, but I dont know how. There doesn't seem to be a way in IE to stop and trap a new window event, or to pause it before running javascript, at least that i know of. Perhaps I can trap it somehow from the web browser control? I get script errors when trying to handle the popup back into the web browser control though but maybe I can dump the source somehow.

    What happens now is:

    Login > Redirect to authentication > Display Web Page

    And after the login I lose all control. I guess there is no way in IE to disable certain javascript events like closing/creating a new window from say internet options, etc. I guess I will try to disable javascript and see what happens (if itll give me the page source). I suppose the other thing I can do is create a new form with webbrowser control and send it that way, not sure but I assume it will freak out
    Last edited by jayinthe813; Mar 7th, 2013 at 10:59 PM.

  4. #4
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    Re: possible to force IE onto a form?

    if its from login then it may be in the source code from that page, dont submit anything just grab the source from there, i beleive you can disable the processing of javascript, but that may just error depending on the page setup.
    My CodeBank Submissions
    • Listbox with transparency and picture support - Click Here
    • Check for a true internet connection - Click Here
    • Open Cash drawer connected to receipt printer - Click Here
    • Custom color and size border around form - Click Here
    • Upload file to website without user logins, includes PHP - Click Here
    • List All Removable USB Storage Devices - Click Here
    • Custom On/Off Slide Control - Click Here
    • Insert multiple rows of data into one database table using parameters - Click Here
    • Trigger USB/Serial Cash Drawer - Click Here

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: possible to force IE onto a form?

    This is an example of the landing page that is forcing the javascript. I was able to disable scripting and grab the source:

    Code:
    <SCRIPT language="Javascript">
     
     
     
    <!--
     
    var sWidth = screen.availWidth-10;
     
     
     
    var sHeight = screen.availHeight-50;
     
     
     
    var demo=window.open('/url/path/to/open', '', 'scrollbars,status,width=' + sWidth + ',height=' + sHeight);
     
     
      
     
    demo.moveTo(0,0);
     
     
     
    window.opener = top;
     
    //opener.close();
     
    window.open("javascript:'<script>window.close()</script>'", "_self"); 
     
     
     
    //-->
     
     
     
    </SCRIPT>
    So how do I handle the JS to not open a new window as the control encounters it?

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: possible to force IE onto a form?

    bump?

  7. #7
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    Re: possible to force IE onto a form?

    Hi,
    there is 2 things you would need to change in the document.

    Code:
    var demo=window.open('/url/path/to/open', '', 'scrollbars,status,width=' + sWidth + ',height=' + sHeight);
    
    and 
    
    window.open("javascript:'<script>window.close()</script>'", "_self");
    unfortunately my javascript is not so up to date but I know these are the ones needing to be changed
    My CodeBank Submissions
    • Listbox with transparency and picture support - Click Here
    • Check for a true internet connection - Click Here
    • Open Cash drawer connected to receipt printer - Click Here
    • Custom color and size border around form - Click Here
    • Upload file to website without user logins, includes PHP - Click Here
    • List All Removable USB Storage Devices - Click Here
    • Custom On/Off Slide Control - Click Here
    • Insert multiple rows of data into one database table using parameters - Click Here
    • Trigger USB/Serial Cash Drawer - Click Here

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: possible to force IE onto a form?

    right, but how do you intercept them in the document before the javascript event occurs?

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: possible to force IE onto a form?

    I guess im going to try to handle it like so i suppose:

    on the new_window event:

    Code:
            If sender.documenttext.contains("window.open") Then
                e.Cancel = True
                WebBrowser1.Navigate("/url/path/to/open") 'plug in the new window url as string and see what happens
            End If
    Not sure if this will work, but if not back to the old drawing board

  10. #10
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    Re: possible to force IE onto a form?

    or just rewrite the event code completely.
    My CodeBank Submissions
    • Listbox with transparency and picture support - Click Here
    • Check for a true internet connection - Click Here
    • Open Cash drawer connected to receipt printer - Click Here
    • Custom color and size border around form - Click Here
    • Upload file to website without user logins, includes PHP - Click Here
    • List All Removable USB Storage Devices - Click Here
    • Custom On/Off Slide Control - Click Here
    • Insert multiple rows of data into one database table using parameters - Click Here
    • Trigger USB/Serial Cash Drawer - Click Here

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width