mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 14:54:57 +00:00

By replacing the `page_did_request_scroll_to()` calls with a request to perform scrolling in the corresponding navigable, we ensure that the scrolling of iframes will scroll within them instead of triggering scroll of top level document.
23 lines
720 B
HTML
23 lines
720 B
HTML
<!DOCTYPE html>
|
|
<link rel="match" href="reference/scroll-iframe-ref.html" />
|
|
<style>
|
|
iframe {
|
|
width: 200px;
|
|
height: 200px;
|
|
border: 1px solid black;
|
|
}
|
|
</style>
|
|
<body></body>
|
|
<script>
|
|
const iframe = document.createElement("iframe");
|
|
iframe.srcdoc = `
|
|
<style>body { margin: 0 }</style>
|
|
<div style="width: 200px; height: 200px; background-color: darkblue"></div>
|
|
<div style="width: 200px; height: 200px; background-color: blue"></div>
|
|
<div style="width: 200px; height: 200px; background-color: magenta"></div>
|
|
`;
|
|
iframe.onload = function () {
|
|
iframe.contentWindow.scroll(0, 200);
|
|
};
|
|
document.body.appendChild(iframe);
|
|
</script>
|