我想在主域名中添加字符串,也在网站的子链接中添加。
我尝试了以下代码,但主域名没有改变,我想先改变主域名,重新加载网站后所有子链接都应该改变。
if (typeof this.href != "undefined") {
web = this.href.toString().toLowerCase();
}
else{
web = document.location.toString().toLowerCase();
}
function urlAddress() {
confirm('Would you like to clear the cache.......... of '+ web + '- Ninja :)');
//window.location.replace(web + "/?NoCDN=123");
var stateObj = web;
if (window.history.state) {
history.pushState(stateObj, "page 1", "/?NoCDN=123");
}
}
/*Second Function
This code is changing all URL of the website...*/
function linkAddress() {
$('a[href]').each(function(){
var link = this.href;
$(this).attr('href',link + '?NoCDN=123');
});
$('script[src]').each(function(){
var link = this.href;
$(this).attr('src',link + '?NoCDN=123');
});
$('link[href]').each(function(){
var link = this.href;
$(this).attr('href',link + '?NoCDN=123');
});
$('img[src]').each(function(){
var link = this.src;
$(this).attr('src',link + '?NoCDN=123');
});
}
//I am calling both functions here ...
$( document ).ready(function() {
urlAddress();
setTimeout(function(){
alert("It's Almost clear. Just click Ok for more result.");
linkAddress();
}, 3000);
});