Launch with javascript in new window/tab

Discussions and Tech Support specific to the iMacros for Chrome extension.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
wandrian
Posts: 2
Joined: Wed May 20, 2020 3:51 pm

Launch with javascript in new window/tab

Post by wandrian » Thu May 21, 2020 7:14 pm

Config Info: iMacros - 10.0.5 (Free) + Chrome Version 83.0.4103.61 (Official Build) (64-bit) + Windows 10 Build 19551.

I have a macro I'm launching via javascript on the click of a button.

version 1

Code: Select all

var macroSource = {
    'thing1': 'URL GOTO=https://localhost/thing1',
    'thing1': 'URL GOTO=https://localhost/thing12,
}
function fillForm(thing) {
    try {
        var macro = {};
        macro.source = macroSource[thing];
        macro.name = 'Fill Form for thing ' + thing;
        var evt = document.createEvent("CustomEvent");
        evt.initCustomEvent("iMacrosRunMacro", true, true, macro);
        window.dispatchEvent(evt);
    } catch(e) {
        alert('iMacros Bookmarklet error: '+e.toString());
    }
}
which works fine (the real thing is obvs more complex, I've edited for clarity), but overwrites the page it is launched from.

I tried version 2

Code: Select all

function fillTIForm(thing) {
    try {
        var macro = {};
        macro.source = macroSource[thing];
        macro.name = 'Fill Form for thing ' + thing;
        new_window = window.open("", "_blank");
        var evt = new_window.document.createEvent("CustomEvent");
        evt.initCustomEvent("iMacrosRunMacro", true, true, macro);
        new_window.dispatchEvent(evt);
    } catch(e) {
        alert('iMacros Bookmarklet error: '+e.toString());
    }
}
which opens a new tab, but then nothing happens. Has anyone got this kind of thing working successfully? Is there a parameter I can pass to the iMacrosRunMacro event that would do this?
Possibly related to this post by ghundermark.
Post Reply