location.hrefジャンプ時のブラウザ別のRefererの設定
1682 ワード
Your post title shows that you want to change the current page programmatially using JavaScript but still having the HTTP referrer provided
You need to be aware of cross-browser ises:
The HTTP referrer header(HTTP-referer)is set when change window.locations.href under the following browsers:
MSIE 9(but probably any version above 9)
Firefox(at least 3.0,3.5,4.0,5.0,but most probably all versions)
Chrome(at least 9、but most probably all versions)
Safari(at least 5,but most probably all versions)
Opera(at least 11,but most probably all versions)
MSIE(at least 6,7,\8):the referrer is not set when change window.locations.href
Firefox(at least 3.0,3.5,4.0):the click function does not exist(this is why some pspeudio-soutions are based on myLink.click()
Firefox 5:the click function exists under Firefox 5 but does not change the window location、so all the methods relying on the existencof the myLink.click()method will not work.Calling myLink.Calling myLink.onicick.onclclclick(clclclclicicick))myclclclclclclclclicick.mmyclclicicicicicicicicicicicick(clclclclclclclclclclclicse))))myclinininininininininse(clclclclclick.
You need to be aware of cross-browser ises:
The HTTP referrer header(HTTP-referer)is set when change window.locations.href under the following browsers:
MSIE 9(but probably any version above 9)
Firefox(at least 3.0,3.5,4.0,5.0,but most probably all versions)
Chrome(at least 9、but most probably all versions)
Safari(at least 5,but most probably all versions)
Opera(at least 11,but most probably all versions)
MSIE(at least 6,7,\8):the referrer is not set when change window.locations.href
Firefox(at least 3.0,3.5,4.0):the click function does not exist(this is why some pspeudio-soutions are based on myLink.click()
Firefox 5:the click function exists under Firefox 5 but does not change the window location、so all the methods relying on the existencof the myLink.click()method will not work.Calling myLink.Calling myLink.onicick.onclclclick(clclclclicicick))myclclclclclclclclicick.mmyclclicicicicicicicicicicicick(clclclclclclclclclclclicse))))myclinininininininininse(clclclclclick.
var navigatorName = "Microsoft Internet Explorer";
if (navigator.appName == navigatorName){ //IE location.href referer
var referLink = document.createElement('a');
referLink.href = url;
document.body.appendChild(referLink);
referLink.click();
} else {
location.href = url;
}