我想要做的是将随机数附加到网址,以便 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/