div getClientRects

AngDH發表於2024-07-26

;var aa = document.createElement('div');
aa.style.cssText = '\n        position: absolute;\n        left: -9999px;\n        font-size: 14px;\n        font-family: Arial, sans-serif;\n      ';
aa.textContent = 'BrowserScan ClientRects Test';
document.body.appendChild(aa);

var ab = aa.getClientRects();
var ac = Array.from(ab).map(function(zz) {
    debugger;
    return {
        'top': zz['top'],
        'right': zz['right'],
        'bottom': zz['bottom'],
        'left': zz['left'],
        'width': zz['width'],
        'height': zz['height']
    };
});
document['body']['removeChild'](aa);

console.log(JSON.stringify(ac));

相關文章