Last active
November 15, 2022 02:27
-
-
Save GoToLoop/9eeb3ea918e9e149ba3c6c717cfb16e1 to your computer and use it in GitHub Desktop.
Expands Current iFrame Element to Fit Body's Size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function adjustFrameSize() { | |
if (frameElement) { | |
frameElement.height = frameElement.frameBorder = 0; | |
frameElement.height = getDocHeight() + 'px'; | |
frameElement.width = getDocWidth() + 'px'; | |
} | |
} | |
function getDocWidth() { | |
return Math.max( | |
document.body.scrollWidth, document.documentElement.scrollWidth, | |
document.body.offsetWidth, document.documentElement.offsetWidth, | |
document.body.clientWidth, document.documentElement.clientWidth | |
); | |
} | |
function getDocHeight() { | |
return Math.max( | |
document.body.scrollHeight, document.documentElement.scrollHeight, | |
document.body.offsetHeight, document.documentElement.offsetHeight, | |
document.body.clientHeight, document.documentElement.clientHeight | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
adjustFrameSize = -> | |
if frameElement | |
frameElement.height = frameElement.frameBorder = 0 | |
frameElement.height = getDocHeight() + 'px' | |
frameElement.width = getDocWidth() + 'px' | |
getDocWidth = -> | |
Math.max( | |
document.body.scrollWidth, document.documentElement.scrollWidth | |
document.body.offsetWidth, document.documentElement.offsetWidth | |
document.body.clientWidth, document.documentElement.clientWidth | |
) | |
getDocHeight = -> | |
Math.max( | |
document.body.scrollHeight, document.documentElement.scrollHeight | |
document.body.offsetHeight, document.documentElement.offsetHeight | |
document.body.clientHeight, document.documentElement.clientHeight | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @ts-check | |
"use strict"; | |
function adjustFrameSize() { | |
/** @type {HTMLIFrameElement} */ | |
const frame = frameElement; | |
if (frame) { | |
frame.height = frame.frameBorder = '0'; | |
frame.height = getDocHeight() + 'px'; | |
frame.width = getDocWidth() + 'px'; | |
} | |
} | |
function getDocWidth() { | |
return Math.max( | |
document.body.scrollWidth, document.documentElement.scrollWidth, | |
document.body.offsetWidth, document.documentElement.offsetWidth, | |
document.body.clientWidth, document.documentElement.clientWidth | |
); | |
} | |
function getDocHeight() { | |
return Math.max( | |
document.body.scrollHeight, document.documentElement.scrollHeight, | |
document.body.offsetHeight, document.documentElement.offsetHeight, | |
document.body.clientHeight, document.documentElement.clientHeight | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default adjustFrameSize = -> | |
if frameElement | |
frameElement.height = frameElement.frameBorder = 0 | |
frameElement.height = getDocHeight() + 'px' | |
frameElement.width = getDocWidth() + 'px' | |
export getDocWidth = -> | |
Math.max( | |
document.body.scrollWidth, document.documentElement.scrollWidth | |
document.body.offsetWidth, document.documentElement.offsetWidth | |
document.body.clientWidth, document.documentElement.clientWidth | |
) | |
export getDocHeight = -> | |
Math.max( | |
document.body.scrollHeight, document.documentElement.scrollHeight | |
document.body.offsetHeight, document.documentElement.offsetHeight | |
document.body.clientHeight, document.documentElement.clientHeight | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @ts-check | |
export default function adjustFrameSize() { | |
/** @type {HTMLIFrameElement} */ | |
const frame = frameElement; | |
if (frame) { | |
frame.height = frame.frameBorder = '0'; | |
frame.height = getDocHeight() + 'px'; | |
frame.width = getDocWidth() + 'px'; | |
} | |
} | |
export function getDocWidth() { | |
return Math.max( | |
document.body.scrollWidth, document.documentElement.scrollWidth, | |
document.body.offsetWidth, document.documentElement.offsetWidth, | |
document.body.clientWidth, document.documentElement.clientWidth | |
); | |
} | |
export function getDocHeight() { | |
return Math.max( | |
document.body.scrollHeight, document.documentElement.scrollHeight, | |
document.body.offsetHeight, document.documentElement.offsetHeight, | |
document.body.clientHeight, document.documentElement.clientHeight | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function adjustFrameSize() { | |
const frame = frameElement as HTMLIFrameElement; | |
if (frame) { | |
frame.height = frame.frameBorder = '0'; | |
frame.height = getDocHeight() + 'px'; | |
frame.width = getDocWidth() + 'px'; | |
} | |
} | |
export function getDocWidth() { | |
return Math.max( | |
document.body.scrollWidth, document.documentElement.scrollWidth, | |
document.body.offsetWidth, document.documentElement.offsetWidth, | |
document.body.clientWidth, document.documentElement.clientWidth | |
); | |
} | |
export function getDocHeight() { | |
return Math.max( | |
document.body.scrollHeight, document.documentElement.scrollHeight, | |
document.body.offsetHeight, document.documentElement.offsetHeight, | |
document.body.clientHeight, document.documentElement.clientHeight | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function adjustFrameSize() { | |
const frame = frameElement as HTMLIFrameElement; | |
if (frame) { | |
frame.height = frame.frameBorder = '0'; | |
frame.height = getDocHeight() + 'px'; | |
frame.width = getDocWidth() + 'px'; | |
} | |
} | |
function getDocWidth() { | |
return Math.max( | |
document.body.scrollWidth, document.documentElement.scrollWidth, | |
document.body.offsetWidth, document.documentElement.offsetWidth, | |
document.body.clientWidth, document.documentElement.clientWidth | |
); | |
} | |
function getDocHeight() { | |
return Math.max( | |
document.body.scrollHeight, document.documentElement.scrollHeight, | |
document.body.offsetHeight, document.documentElement.offsetHeight, | |
document.body.clientHeight, document.documentElement.clientHeight | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment