Thursday, January 20, 2011

MSIE and incorrect .src and .href (final solution ?)

Could this be a final solution for uri resolving in .src and .href for MSIE ? (blogged before, search..)

function getUriRef(element, attrName) {
    //MSIE sometimes returns unnormalized .src or .href property 
    //for LINK and SCRIPT tags, it has not been observed on a.href
    // example: s.src returns "sss" instead of ptoto://auth/sss
    // this is observable always on "some" pages and "some" elements
    // in case .src does not work -> getAttribute('src',4) works
    // when .src works (returns abs. uri), getAttribute('src',4) does not work and returns (raw)
    // TODO: detect, dont do always, study reason why this happens
    var uri = element[attrName];
    if (uri != null) {
        if (!(/^[A-Z][0-9A-Z+\-\.]*:/i).test(uri)) {
            //TODO: TEST XB for additional param, but i dont expect any normal browser to fail here
            uri = element.getAttribute(attrName, 4);
    return uri;

No comments:

Post a Comment