Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jordanrios94/d69aa3ac7adc78a93962bc242e13ae8e to your computer and use it in GitHub Desktop.
Save jordanrios94/d69aa3ac7adc78a93962bc242e13ae8e to your computer and use it in GitHub Desktop.
Iframe scrolling parent window
// IFRAME
(function () {
const scrollParentWindow = (x = 0, y = 0) => {
const parentWin = window.parent,
parentExpectedUrl = 'PARENT_URL_HERE',
currentParentUrl = `http://${parentWin.location.hostname}`
if (parentExpectedUrl === currentParentUrl) {
parentWin.postMessage({
xAxis: x,
yAxis: y
}, parentExpectedUrl)
}
return false
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment