Created
April 18, 2018 13:31
-
-
Save jordanrios94/d69aa3ac7adc78a93962bc242e13ae8e to your computer and use it in GitHub Desktop.
Iframe scrolling parent window
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
// 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