js 页面所有超链接后加随机数 基于jquery
生活随笔
收集整理的這篇文章主要介紹了
js 页面所有超链接后加随机数 基于jquery
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
避免了頁面緩存問題。
??????????? rand = Math.random();
???? $("a").each(function () {
??????????????? href = $(this).attr("href");
??????????????? if (href.length == 0 || href.indexOf("javascript") > -1) return;
??????????????? else if (href.indexOf("?") > -1) {
??????????????????? $(this).attr("href", href + "&" + rand);
??????????????? }
??????????????? else {
??????????????????? $(this).attr("href", href + "?" + rand);
??????????????? }
??????????? });
??????????? rand = Math.random();
???? $("a").each(function () {
??????????????? href = $(this).attr("href");
??????????????? if (href.length == 0 || href.indexOf("javascript") > -1) return;
??????????????? else if (href.indexOf("?") > -1) {
??????????????????? $(this).attr("href", href + "&" + rand);
??????????????? }
??????????????? else {
??????????????????? $(this).attr("href", href + "?" + rand);
??????????????? }
??????????? });
總結
以上是生活随笔為你收集整理的js 页面所有超链接后加随机数 基于jquery的全部內容,希望文章能夠幫你解決所遇到的問題。