【问题标题】:Randomly redirect to url BUT 1 number changes (via Javascript)随机重定向到 url 但 1 个数字更改(通过 Javascript)
【发布时间】:2018-09-03 02:05:41
【问题描述】:

所以,我使用这个代码

<script type="text/javascript">

var urls = new Array();
urls[0] = "/truth";
urls[1] = "/truth1";
urls[2] = "truth2";

var random = Math.floor(Math.random()*urls.length);

window.location = urls[random];

</script>

我使用“/truth1”“/truth2”“dare1”等

是否有可能让 javascript 在我设置的 URL 末尾自动放置一个随机数?

换句话说 我希望 Javascript 在末尾添加一个数字
truthordare0.weebly.com/truth
truthordare0.weebly.com/dare

到 truthordare0.weebly.com/dare1,truthordare0.weebly.com/dare2
到truthordare0.weebly.com/truth1,truthordare0.weebly.com/truth2
在 "truth" 或 "dare" 的末尾放一个 1-25 之间的随机数。如果我必须将数字设为两位数,请告诉我!



了解一下可能会很方便:
-上面的代码将用于truthordare0.weebly.com/truth
(将重定向到 /truth1/truth2 等 -以上代码在vitemulti.weebly.com/yesorno-select中使用

非常感谢!!

【问题讨论】:

  • 你有什么问题?不清楚你想要什么

标签: javascript html url redirect random


【解决方案1】:

<script type="text/javascript">

var urls = new Array();
urls[0] = "/truth";
urls[1] = "/truth1";
urls[2] = "truth2";

var random = Math.floor(Math.random()*urls.length);

window.location = "https://truthordare0.weebly.com/" + urls[random];

</script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多