gpt4 book ai didi

javascript - 尝试在 JavaScript 中附加随机变量

转载 作者:行者123 更新时间:2023-11-28 21:15:47 25 4
gpt4 key购买 nike

我想要做的是将随机数附加到网址,以便 http://fwe.a + .apple.com 就像 http://fwe.randomnumber.apple.com ..正确的方法是什么

<script type="text/javascript" charset="utf-8"> 
var a=Math.floor(Math.random()*99999);
FB.Event.subscribe('edge.create', function(response) {
window.location = "http://google.com/";
});
var link = "http://fwe.a + .apple.com";
var bad = "fb_xd_fragment";
var url = top.location.href;
if( url.substr(-bad.length) === bad ) {
top.location = url.substr(0, url.length-bad.length-1);
}
</script>

最佳答案

唯一看起来错误的是 link 变量的串联。

    <script type="text/javascript" charset="utf-8">
var a = Math.floor(Math.random()*99999);
FB.Event.subscribe('edge.create', function(response) {
window.location = "http://google.com/";
});
var link = "http://fwe." + a + ".apple.com";
var bad = "fb_xd_fragment";
var url = top.location.href;
if( url.substr(-bad.length) === bad ) {
top.location = url.substr(0, url.length-bad.length-1);
}
</script>

关于javascript - 尝试在 JavaScript 中附加随机变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7642036/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com