5

How do I execute JavaScript from an iMacro script?

URL GOTO=javascript:alert("TEST");

The Javascript works fine when pasting it into the address bar (by putting "javascript:" in front of the code) but unfortunately iMacros does not recognize this as a valid URL.

So since this doesn't work, what's the correct way to run JavaScript from an iMacro script?

George Stocker
  • 57,289
  • 29
  • 176
  • 237
Meowls
  • 59
  • 1
  • 5

2 Answers2

4

Try something without a dialog. For example: URL GOTO=javascript:console.log("TEST"); or URL GOTO=javascript:function<SP>test(){status="TEST"};void<SP>test();

Shugar
  • 5,269
  • 1
  • 9
  • 9
0

make a separate java-script file and then call it from your macro using

URL GOTO=imacros://run/?m=your-javascript.js

note that this method is not actually perfect cause imacros does not support calling javascript files from within macros, so this is a workaround and may have certain side effects - enterprise imacros support callback for javascript files.

ehab
  • 7,162
  • 1
  • 25
  • 30