本文介绍了为什么这个脚本永远不会运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下JavaScript语句,它在Page Load上执行:

I've got the following JavaScript statement, that executes on Page Load:

变量 u1 是填充以下值之一:

The variable u1 is populated with one of the following values:

BBSLoan |接受| PPI +否| 60Months

BBSLoan | Refer | PPI + No | 60Months

HSBSLoan |接受| PPI +否| 48Months

HSBSLoan |推荐| PPI +否| 48个月

我去过告知条件陈述中的条件永远不会得到满足 - 这是真的吗?从我所看到的,继续每个变量, indexOf 将返回的索引是 0 ?除非我弄错了?

I have been informed that the conditions in the conditional statements will never be met - is this true? From what I can see, going on each of the variables, the index that will be returned by indexOf is 0? Unless I am mistaken?

编辑:为了澄清,变量'u1'将动态填充上面列出的4个字符串中的任何一个。 %pu1 =!; 实际上是一个将填充此值的宏。

Just to clarify, the variable 'u1' will be populated dynamically with any of the 4 strings listed above. The %pu1=!; is actually a macro that will populate this value.

<script language="JavaScript" type="text/javascript">
    var u1 = '%pu1=!;';

    if (u1.indexOf('BBSLoan|Accept') > -1) {
        var pvnPixel = '<img src="http://www.url1.com"/>';
        document.writeln(pvnPixel);
    }
    if (u1.indexOf('BBSLoan|Refer') > -1) {
        var pvnPixel2 = '<img src="https://www.url2.com;"/>';
        document.writeln(pvnPixel2);
    }
    if (u1.indexOf('HSBSLoan|Accept') > -1) {
        var pvnPixel3 = '<img src="https://www.url3.com;"/>';
        document.writeln(pvnPixel3);
    }
</script>

提前致谢!

推荐答案

好的我终于使用搜索而不是 indexOf

Ok I finally got this to work using search instead of indexOf!

这篇关于为什么这个脚本永远不会运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 05:17