리디렉션을 위해 내 js 파일에 대해 아래 코드를 사용하고 있습니다. 그러나 최상위 위치를 기반으로 리디렉션을 원합니다. 예를 들어 누군가 xyz.com을 방문하여 mydomain.com으로 리디렉션하면 어떤 코드를 추가해야합니까? 나는 문서 위치에 따라 Js 파일에서 리디렉션
는 항상 현재 표시된 웹 페이지를 참조하는 객체이다loadScript("http://j.maxmind.com/app/geoip.js", function() {
var country = geoip_country_code();
if (country === "US") {
window.location = "http://mydomain.com/";
}
});
function loadScript(url, callback) {
// adding the script tag to the head as suggested before
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
// then bind the event to the callback function
// there are several events for cross browser compatibility
script.onreadystatechange = callback;
script.onload = callback;
// fire the loading
head.appendChild(script);
}
와
를 대체 할 수있는 나는 적어도 자바와 PHP 태그는이 질문에 대한 부적절한 생각합니다. 또한, 아마도 html 태그 – jpm