3

I want to check if an HTML element exist with iMacros. If it does, I want to go to a URL. If not, I want to go to other URL.

Because iMacros doesn't have statements, I used javascript with the iMacros' EVAL. Here is the line that handles the javascript execution:

SET !VAR3 EVAL("var element = window.content.document.getElementById(\"some_element\");
if (typeof(element) != 'undefined' && element != null) { 
var redirect = 'http://192.168.178.22/sc/report.php'; 
} else { 
var redirect = 'http://192.168.178.22/sc/index.php?action=connect'; 
} 
redirect;
")

*It's all in one line, but I formatted it for here.

Then, I will redirect with

URL GOTO={{!VAR3}}

The problem is in both of the cases, the !VAR3 is set to 'undefined.'

I tried almost the same JS code on Firefox only, and it seems to be working.

Windows 8 with the latest Firefox and the latest iMacros version.

Thank you.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
user2312194
  • 33
  • 1
  • 1
  • 3

1 Answers1

4
var macro;

macro ="CODE:";
macro +="TAG POS=1 TYPE=DIV ATTR=CLASS:some_class CONTENT=EVENT:MOUSEOVER ";

var ret=null;

ret=iimPlay(macro);

if(ret>0)
{
//do something
}
else
{
//do something else
}

This would be the basic model of the script you want. You just have to insert the proper imacros code.

edinvnode
  • 3,497
  • 7
  • 30
  • 53
  • 1
    Thanks for your response. But, it's a little unclear for me. Should I use the Scripting Interface for this? Please be more specific. Thanks again for your help. – user2312194 Apr 25 '13 at 13:43
  • The scripting interface means nothing other then this. Instead of .iim file you use .js file . And in my post you have an example of how to mame .js file. – edinvnode Apr 27 '13 at 12:43
  • The response above is barely understandable. This is coming a little late, but here's the answer clarified: No you don't need the scripting interface. The scripting interface you're referring to is probably the standard/professional edition feature. You can run .js files just like you can run .iim files in the free version. Just save the .js file in the directory where iMacros is pointed (discernible through the settings menu). Caveat: I am unable to get .js files to show up in Chrome's plugin. The Firefox plugin seems much more stable/functional. – Tyler Hoppe Oct 01 '15 at 18:01
  • @user2312194, add between macro +="SET !ERRORIGNORE YES\n"; – Fortran Nov 17 '16 at 14:47