0

我有一些 JavaScript 代码在屏幕上打印一个随机字符串,而不是随机数字和字母,只是我创建的单词。所以我需要它,所以如果它随机选择某个字符串,它会将您重定向到不同的页面。

4

2 回答 2

5
if (randomString == 'patternString') {
   window.location.href = 'http://google.com';
}
于 2013-01-21T22:27:15.363 回答
0
window.location.href = 'https://www.google.com/search?q=' + encodeURIComponent(randomString);
于 2013-01-21T22:37:16.247 回答