简体   繁体   English

如何在imacros中获取全局javascript变量?

[英]How to get global javascript variables in imacros?

I am using imacros to code in javascript and i cant seem to retrieve variables from the website pages javascript. 我正在使用imacros在javascript中编码,我似乎无法从网站页面javascript中检索变量。

In the javascript for the page the variable is window.vVals = (variable value here) 在页面的javascript中,变量是window.vVals =(这里是变量值)

I need to get that using imacros, how would i do that? 我需要使用imacros,我该怎么做? I have tried various things window.vVals vVals window.content.vVals But they all return undefined, its really frustrating now 我已经尝试了各种各样的东西window.vVals vVals window.content.vVals但它们都返回undefined,现在真的很令人沮丧

Thanks 谢谢

Edit: 编辑:

<script>
window.vVals = {
'f': 'frm_sample',
'n': '57064044135dd',
'a': '57067289aa2c6'
};
</script>

The above is the code that is on the web page 以上是网页上的代码

Using IMacros i would like to retrieve the values of those variables (the values change everytime you refresh which is why i cant use any 1 value) 使用IMacros我想检索这些变量的值(每次刷新时值都会改变,这就是为什么我不能使用任何1个值)

Below is one of the possible solutions: 以下是可能的解决方案之一:

iimPlayCode('SEARCH SOURCE=REGEXP:"(window\\\\.vVals = ((\\\\s|.)*?);)" EXTRACT=$2');
var vVals = JSON.parse(iimGetExtract().replace(/'/g, '"'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM