Pages: 1
Print
Author Topic: XMetal marco unable to run window.open(url)  (Read 150 times)
akheiljain
Member

Posts: 5


« on: June 21, 2017, 02:52:04 PM »

XMetal macro JScript wont run
window.open
window.addEventListener

does any one know why or how to make it work?
Logged
tonys
JustSystems Partner
Member

Posts: 78


« Reply #1 on: June 21, 2017, 04:57:39 PM »

The window object is implemented by web browsers. Since XMetaL is not a browser, it doesn't exist.
Logged
akheiljain
Member

Posts: 5


« Reply #2 on: June 22, 2017, 08:44:03 AM »

Hi Tonys,
 Thank you for your reply, would there be another way to accomplish this in XMetal, I need to launch a URL window, attach an event listener to it and get event data back. I am able to run the JS directly through Chrome, but not sure how to accomplish it through an xmetal macro.
Logged
tonys
JustSystems Partner
Member

Posts: 78


« Reply #3 on: June 22, 2017, 03:34:58 PM »

A good place to start would be the Windows Scripting Host documentation. It will tell you what is available to all applications that implement JScript.
Logged
tonys
JustSystems Partner
Member

Posts: 78


« Reply #4 on: June 22, 2017, 03:49:19 PM »

This topic might also be relevant: http://forums.xmetal.com/index.php/topic,3706.0.html
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2481



WWW
« Reply #5 on: June 22, 2017, 05:23:22 PM »

I'm not sure what the exact final goal is but perhaps one of these posts that include some example code will help?

http://forums.xmetal.com/index.php/topic,512
http://forums.xmetal.com/index.php/topic,514
Logged
akheiljain
Member

Posts: 5


« Reply #6 on: July 06, 2017, 09:59:05 AM »

Hi Derek,
I was able to run my js using the sample http://forums.xmetal.com/index.php/topic,514.0.html, but once the event takes place in the browser window, it doesn't report the event back to XMetal.
I have the mcr set to :
<?xml version="1.0"?>
<!DOCTYPE MACROS SYSTEM "macros.dtd">
<MACROS>
   <MACRO name="On_Application_Open_Complete" lang="JScript" hide="true"><![CDATA[
      // XMetaL Script Language JSCRIPT:
      ResourceManager.Visible = true;
      ResourceManager.RemoveTab( "Assets" );
      ResourceManager.RemoveTab( "Desktop" );
      ResourceManager.RemoveAllTabs();
      ResourceManager.AddTab("Web Service","Shell.Explorer");
      ResourceManager.SelectTab("Web Service");
      WebService = ResourceManager.ControlInTab( "Web Service" );
      WebService.navigate( "file:///C:/Program%20Files%20(x86)/XMetaL%209.0/Author/Forms/resManTest.html" );
   ]]></MACRO>
</MACROS>

And the html file looks like :
window.open("http://hw-en-daem-ap01:8080","Picker")
if(window.addEventListener) {
        window.addEventListener("message", receiveMessage, false);
    }//if
    else if (window.attachEvent) {
        window.attachEvent("onmessage", receiveMessage, false);
    }//else
 
    function receiveMessage(event) {
        console.log("Received message from: " + event.origin);
 }

The receiveMessage is never called.
Logged
Pages: 1
Print
Jump to:  

email us