trying to append random variables in javascript
What i'm trying to do is append a random number to the url so that http://fwe.a + .apple.com is like http://fwe.randomnumber.apple.com ..what is the right way to do this
<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>
The only thing that looks wrong is your concatenation of the link
variable.
<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>
var link = "http://fwe." + a + ".apple.com";
精彩评论