<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<iframe id="iframeTxt1" src="longlong.txt"></iframe>
<iframe id="iframeTxt2" src="longlong.txt"></iframe>
<script>
var iframe1 = document.getElementById("iframeTxt1");
var iframe2 = document.getElementById("iframeTxt2");
function scroll1() {
iframe2.contentWindow.scrollTo(0,iframe1.contentWindow.pageYOffset);
}
function scroll2() {
iframe1.contentWindow.scrollTo(0,iframe2.contentWindow.pageYOffset);
}
document.addEventListener('DOMContentLoaded', function() {
iframe1.addEventListener('load', (function(element) {
return function() {
element.contentWindow.addEventListener('scroll', scroll1);
};
})(iframe1, false));
iframe2.addEventListener('load', (function(element) {
return function() {
element.contentWindow.addEventListener('scroll', scroll2);
};
})(iframe2, false));
}, false);
</script>
</body>
</html>
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme