iframe cross-origin positioning
My starting point.
by jib1
HTML
<div id="container">
</div>
CSS
#container
{
display: table-cell
}
#outerdiv
{
width: 40px;
height: 40px;
overflow: hidden;
position: relative;
}
#inneriframe
{
position: absolute;
width: 450px;
height: 450px;
}
JavaScript
const url = "https://jan-ivar.github.io/dummy/accountinfo.html";
//const url = "https://jan-ivar.github.io/dummy/logo.html";
let arr = [...Array(100).keys()].map(n => ([n % 10, Math.floor(n / 10)]));
shuffle(arr);
const iframes = [];
for (let y = 0; y < 10; y++) {
const container = document.documentElement.appendChild(document.createElement("div"));
container.id = "container";
for (let x = 0; x < 10; x++) {
const div = container.appendChild(document.createElement("div"));
div.id = "outerdiv";
const iframe = div.appendChild(document.createElement("iframe"));
iframe.id = "inneriframe";
const [px, py] = arr[x + y*10];
iframe.style =`top: -${(px + 1) * 40}px; left: -${(py + 1) * 40}px;`
iframe.src = url;
iframes.push(iframe);
}
}
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
(async () => {
try {
await wait(5000);
let i = 0;
for (const iframe of iframes) {
const x = i % 10;
const y = Math.floor(i++ / 10);
iframe.style =`top: -${(x + 1) * 40}px;` +
`left: -${(y + 1) * 40}px; transition-duration: 5s;`
}
} catch (e) {
console.error(e);
}
})();
function shuffle(array) {
let currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}