一个js里的函数的retur值想返回另一个js的变量值,应该怎么写?
这是一个微信号自动更换的代码,有有台批量添加微信号,然后把代码植入推广落地页里面
步骤1.把下面代码拷贝到网页和标签之间
<script type="text/javascript" > weixin="默认微信" </script> <script type="text/javascript" src="http://weixin.wecat.top/api/weixin/getwechat.html?webid=d3e9e54f9cb1a793bef84cc21a2778f2"> </script>
<script type="text/javascript"> document.write(weixin); </script>(这个就可以在落地页显示随机读取的微信号)
但是还有一个按钮,就是点击这个按钮会自动复制这个微信号,然后自动跳到微信界面。问题就出现在复制的这个微信号,读取不了上面的变量“weixin”的值。
落地页点击按钮的代码如下:
<button class="jump_btn" style="width: 90%;background: #1AAD19;text-align: center;border:none;color: #fff;margin: 0 auto;box-sizing: border-box;font-size: 18px;line-height: 2.55555556;border-radius: 5px;display: block;text-decoration: none;">点击打开微信添加<img src="{pboot:sitetplpath}/html/img/dj.png"></button><br />
<div align="center"><img src="{pboot:sitetplpath}/html/img/ydtz.gif" width="90%"></div>
<script> function jumpweixin()
{if (!/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent) && / baiduboxapp/i.test(navigator.userAgent)) { window.location.replace("bdbox://utils?action=sendIntent&minver=7.4¶ms=%7B%22intent%22%3A%22weixin://%23wechat_redirect%23Intent%3Bend%22%7D");
}
else{ window.location.replace("weixin://");
}
}
var clipboard = new ClipboardJS(".jump_btn", {text: function () {return "weixin这里只能返回字符串weiixn,并不是weixin的变量的值";}} ); clipboard.on( "success", function ( e ) {jumpweixin(); } ); clipboard.on( "error", function ( e ) { window.location.replace("weixin://"); console.log( e ); } );
</script>
请教怎么写上面的return后面的变量,才能让他返回的值跟上面的 document.write(weixin); 返回的一样呢。