Question

i know how to position iframes via html, but I'm making a bookmarklet, which of course, is javascript.

I've extrapolated the lessons from this question's 2nd answer: Bookmarklet: Append hidden iframe to page and load url

and come up with this:

javascript:var%20ifra=document.createElement('iframe');ifra.src="https://imanerd11.kd.io/temp1.html";ifra.setAttribute("width","194");ifra.setAttribute("height","750");ifra.setAttribute("left","0");ifra.setAttribute("borders","no");ifra.setAttribute("scrollbars","no");ifra.setAttribute("top","0");void(document.body.appendChild(ifra));

enter image description here

  • that's the screenshot of what it does currently.

I need to be able to move this to the side of the page like this:

enter image description here

Was it helpful?

Solution

top and left aren't attributes, they are CSS properties.

You can set the styles programmatically like:

ifra.style.top = '100px';

You can also use the style attribute:

ifra.setAttribute('style', 'top: 10px; left: 10px;');

Note: Do not forget that these will be ignored if the element isin't positionned absolute or relative.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top