用iMacros和javascript检查html元素是否存在 [英] Check if html element exists with iMacros and javascript

查看:170
本文介绍了用iMacros和javascript检查html元素是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查iMacros是否存在HTML元素。如果是这样,我想去一个URL。如果没有,我想去其他网址。

因为iMacros没有语句,所以我在iMacros的EVAL中使用了javascript。
这是处理javascript执行的行:
$ b $ $ $ $ $ $ $ $ $ $ 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;

*全部在一行,然后,我将重定向到

$ p $ URL GOTO = {{!VAR3}}

问题是在这两种情况下, VAR3被设置为'undefined'。



我在Firefox上尝试了几乎相同的JS代码,它似乎正在工作。

使用最新的Firefox和最新的iMacros版本的Windows 8。



谢谢

解决方案

  var macro; 

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

var ret = null;

ret = iimPlay(宏);

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





$ p这是你想要的脚本的基本模型。你只需要插入正确的图像代码。


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.

解决方案

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.

这篇关于用iMacros和javascript检查html元素是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆