开发者

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";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜