Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    May 2013
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Internet Explorer Communication between Jscript in OLE browser control and hosting application

    Hello,

    This is not an ASP.NET question, and I know what I'm trying to do can easily be accomplished using a .NET framework. My company has a win32 app built in PowerBuilder that runs learning e-content (LMS). We are using a Microsoft IE OLE Browser control to launch the content. There is JScript running on the page that needs to communicate with the hosting application.

    I know that due to the single-threaded nature of JScript that this is damn near impossible. There is no window.external function like in ASP.NET. However, I have figured out how to call functions and set variables in JScript from the hosting application. The problem lies in getting the JScript to be able to communicate the other way.

    I have tested many ideas, the last one being using AJAX to read/write from an external file that the hosting application and Jscript would share. The problem with this is that I get an "Permission Denied" error due to the OLE Browser control's security settings (which I don't know how to change).

    I understand that I could use a webservice (which is what I've done in the past), but we are trying to steer away from that at the moment.

    Ultimately I will be trying to get all of the information up front into the JScript from the hosting application; then everything will be encapsulated while the page is running. But of course time is an issue.

    Thoughts??

    Thank you,
    Matt

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    you can bypass security warnings using this to push GET data to any URL:

    Code:
    function ping(url){
      new Image().src=url;
    }
    if you need to send more than 1.9kb at once, you can also build FORM tags using the dom and POST to any domain, and though you may get a click-through warning in some versions with that, it does still work.

    there are several other options as well should these not work out for you...
    Last edited by rnd me; 05-31-2013 at 11:06 PM.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • Users who have thanked rnd me for this post:

    faym (06-01-2013)

  • #3
    New to the CF scene
    Join Date
    May 2013
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you rnd_me! I will try this and post what happens..

  • #4
    New to the CF scene
    Join Date
    May 2013
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    So, I haven't gotten this code to work yet, but I have some questions. How would we read/write to a text file using this Image() DOM object? Is it considered a Node, and therefore does it have a .text property?

    Also, would this method work multiple times throughout a session, or only the first time? Would caching affect the data, since it's an image type?

    I'm curious about the second idea you posted about, concerning FORM tags. Would these objects be considered JScript variables, or are they in a Parent realm?

    Thanks!

  • #5
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    hmm. my code shows you how to get it to another server, not a file.

    sounds like you already have it working minus the security.
    fun fact: you can rename the file something.html to something.hta add the application tag, and almost all security warnings go away.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • #6
    New to the CF scene
    Join Date
    May 2013
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks rnd_me.

    I actually got past the security by moving the file to wwwroot and accessing it using an AJAX object and a http://localhost/ URL (as opposed to a C:\ url).

    This is all happening server-side, on the same server.

    Again, I am trying to obtain real-time communication between JScript (running in an OLE browser control) and the host application. I have tried something like this:

    document.title = "test'; // Trigger titlechange event in host application
    // Host application would theoretically create file for ajax.
    do {
    xmlhttprequest.open("GET", PB_OBJECT_PATH, false);
    xmlhttprequest.send();
    } while (xmlhttprequest.status!=AJAX_OK);

    The problem is that the titlechange event never triggers in the OLE control.

    Since the API I'm working with uses return value functions and not callback functions, I need to return the result by the end of the function in my page (the thread never breaks).

    Can you think of anything on the JScript side of things that can allow me to accomplish this?

    I looked into Narrative JScript (it has a sleep function), but the OLE control pops a security error when I try to run the js compiler...

    Thank you for your help!!

  • #7
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    no need to loop, since you pass false as arg3 to open():


    Code:
    xmlhttprequest.open("GET", PB_OBJECT_PATH, false);
    xmlhttprequest.send();
    alert(xmlhttprequest.responseText);
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • Users who have thanked rnd me for this post:

    faym (06-03-2013)

  • #8
    New to the CF scene
    Join Date
    May 2013
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you! This worked!!

    I was under the impression that I needed it in a while loop because the actual file might not be created when I send the AJAX call... but I guess somehow it keeps trying if it's a sync/false call. Awesome!


  •  

    Tags for this Thread

    Posting Permissions

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