iframe高度自适应

This commit is contained in:
谢思 2022-07-29 14:17:01 +08:00
parent 047ee8fae9
commit 8c3d227d02
1 changed files with 15 additions and 2 deletions

View File

@ -88,7 +88,6 @@ function Data(props){
setSpining(false);
}
x.send();
console.log("spining");
}
function lookResult(taskId){
@ -99,6 +98,19 @@ function Data(props){
}
}
function iframeLoad() {
try {
let myIframe = document.getElementById("htmlIframe");
console.log('myIframe', myIframe, myIframe.contentDocument);
if (myIframe.contentDocument) {
console.log(myIframe.contentDocument.querySelector('.el-main'));
myIframe.height = myIframe.contentDocument.querySelector('.el-main').clientHeight + 260;
// myIframe.contentDocument.querySelector('.admin-body-container').style.overflow = 'hidden';
}
} catch (err) {
console.error(err);
}
}
return(
<div>
<DetectionModal
@ -175,7 +187,8 @@ function Data(props){
</span>
}
</li>
{openResultTaskId && openResultTaskId === e.task_id && <iframe title={`htmlIframe_${key}`} src={lookResultUrl+e.task_id} id={`htmlIframe_${key}`} frameBorder="0" name={`htmlIframe_${key}`} width="100%" height='500px'></iframe>}
{/* lookResultUrl+e.task_id */}
{openResultTaskId && openResultTaskId === e.task_id && <iframe title={`htmlIframe_${key}`} src={lookResultUrl+e.task_id} id={`htmlIframe`} frameBorder="0" name={`htmlIframe_${key}`} width="100%" onLoad={iframeLoad} height={'auto'}></iframe>}
</div>
)
})