您现在的位置是:首页 >其他 >ifream等比缩放,并解决错位bug网站首页其他
ifream等比缩放,并解决错位bug
// 稍微错开空隙,留给滚动条
let scw = $(“#divId”).width()/1700
let scs = $(“#divId”).width()/1680
let sch = $(“#divId”).height()/scs
$(“#ifreamId”).css({height: sch+ ‘px’, width: ‘1680px’, transform: scale(scw)})
// ifream 错位
let deLeft = document.getElementById(‘divId’).getBoundingClientRect().left
let deTop = document.getElementById(‘divId’).getBoundingClientRect().top
let ifLeft = document.getElementById(‘ifreamId’).getBoundingClientRect().left
let ifTop = document.getElementById(‘ifreamId’).getBoundingClientRect().top
// 将ifream 复位
$(“#ifreamId”).css({position: absolute, top: deTop-ifTop, left: deLeft-ifLeft})
// 操作ifream 中的标签,需要ifream加载完成
document.getElementById(‘ifreamId’).onload = () =>{
let tds = document.getElementById(‘ifreamId’).contentWindow.document.getElementByTagName(‘td’)
tds.forEach(x => x.style.color = ‘#FF0000’)
}