views:

322

answers:

1

This macro should activate tabs in sequence from 1th to 5th and then again. But there is something wrong. When you open 5 tabs, activate first of them and run this code in iMacros firefox extension, the 3th tab never is activated:

//imacros-js:showsteps no

var x=1;

while(true)
{
  iimPlay("CODE:TAB T="+x+"\n");
  alert(x);
  x=x+1;
  if (x==6) x=1;
}

But x variable is correct in every moment. There is something wrong with iimPlay(), or my version of iMacros.

A: 

I have found answer in imacros forum:

1st loop: Starting on 1st tab. Your macro goes to 2nd tab with TAB T=1 2nd loop: Starting on 2nd tab. Your macro goes to 4th tab with TAB T=2 3rd loop: Starting on 4th tab. Your macro tries to go to 7th tab with TAB T=3 but can't. The tab doesn't exist, so macro breaks with an error.

And even if you get to 5th tab, you can't move back to 1st tab because iMacros doesn't support negative tab movement (TAB T=-1).

To fix the problem, you could replace your iimPlay line with iimPlay("CODE:TAB T="+x+"\n"+"TAB T=1"); Like that, your macro would always return to 1st tab and retain its functionality.