dimanche 29 novembre 2015

Cannot read property 'getElementById' of undefined

hey i have some code that not working in Chrome and FF, but it is working in IE.

this is the JS code:

var topAppFrame = getFrameByName("smart_payslip");

function getFrameByName(sName) {
    sFrame = "self";

    while (eval(sFrame + "." + sName) == null && eval(sFrame) != top)
        sFrame = sFrame + ".parent"

    if (eval(sFrame + "." + sName) == null)
        return self.top;
    else
        return eval(sFrame + "." + sName)
}


function NavigateSlip(target, linkC) {
     
    var l;
    try {
        for (x = 1; x <= 11; x++) {
            l = topAppFrame.frames["HMain"].document.getElementById("link" + x);
            l.style.backgroundColor = "#003366";
        }
    } catch (e) {

    }
    
   
    var linkC = topAppFrame.frames["HMain"].document.getElementById(linkC);
    linkC.style.backgroundColor = "red";

    topAppFrame.document.frames['SlipArea'].location = target;

}

and this is the C# code:

ClientScript.RegisterClientScriptBlock(this.GetType(), "Msg2", "<script language='javascript'>NavigateSlip('SlipArea.aspx','link2');</script>");

any idea ? I'm really lost... thanks




Aucun commentaire:

Enregistrer un commentaire