有没有方法可以通过文件名检查javascript文件是否已经附加到页面上。
例如:
if ("path-to-script/scriptname.js") already embeded
{
call related function
}
else
{
Append '<script src="path-to-script/scriptname.js" type="text/javascript"> </script> '
call related function
}
基本上我不希望同一页上有两个相同的脚本被附加。
else
,在加载脚本后仅在if-else
块外部调用函数。 - user684934