请帮助我,我可以加载一个标记为html的随机javascript文件吗?我知道这在css中是可能的,但我想尝试使用javascript。或者至少显示javascript代码,有时是,有时不是。
例如,我有两个javascript文件,名为"1.js"和"2.js"。我怎么能在每页载入一个标签?
发布于 2016-04-12 06:37:38
我会将JS文件合并成一个文件。并创建一组随机函数,并在加载文件时执行它们。
//random.js
var array_of_random_function = [function(){
//do something
},
function(){
//do something else
}]
//generate random number as per the length of the above array.
var rand = Math.floor(Math.random()*array_of_random_function.length);
array_of_random_function[i]();https://stackoverflow.com/questions/36563791
复制相似问题