隐藏/显示不同域上的元素

时间:2017-06-15 05:07:34

标签: javascript dns

域名www.novameta.co.uk重定向到iframe的www.novameta.lt/en 当我加载页面脚本工作。但是当我转到下一页脚本停止工作时。当我转到另一个页面时,有没有办法让脚本再次加载?

脚本:

var loc = window.location;
var url = (window.location != window.parent.location)  // checks who I am ?
    ? document.referrer                          // If I'm frame give me parent url 
    : document.location.href;                    // If I'm static simple page, give me browser url
var elementLt = document.getElementById("left-side-lt");
var elementEn = document.getElementById("left-side-en");
var elementContLt = document.getElementById("cont-lt");
var elementContEn = document.getElementById("cont-en");
var elementLangs = document.getElementById("language-bar");
if (url.indexOf("novameta.co.uk") != -1) {
    if (elementLt != null) {
        elementLt.style.display = "none";
    }
    if (elementEn != null) {
        elementEn.style.display = "block";
    }
    if (elementContLt != null) {
        elementContLt.style.display = "none";
    }
    if (elementContEn != null) {
        elementContEn.style.display = "block";
    }
    if (elementLangs != null) {
        elementLangs.style.display = "none";
    }
} else {
    if (elementLt != null) {
        elementLt.style.display = "block";
    }
    if (elementEn != null) {
        elementEn.style.display = "none";
    }
    if (elementContLt != null) {
        elementContLt.style.display = "block";
    }
    if (elementContEn != null) {
        elementContEn.style.display = "none";
    }
    if (elementLangs != null) {
        elementLangs.style.display = "block";
    }
}

0 个答案:

没有答案