How to rotate an iframe using javascript?

by tressie.damore , in category: Javascript , 3 months ago

How to rotate an iframe using javascript?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by adan , 3 months ago

@tressie.damore 

You can rotate an iframe using javascript by applying a CSS transform property to the iframe element. Here is an example code snippet to rotate an iframe element by 90 degrees clockwise:

1
2
3
4
5
6
7
var iframe = document.getElementById("yourIframeId");

iframe.style.transform = "rotate(90deg)";
iframe.style.webkitTransform = "rotate(90deg)";
iframe.style.mozTransform = "rotate(90deg)";
iframe.style.msTransform = "rotate(90deg)";
iframe.style.oTransform = "rotate(90deg)";


Make sure to replace "yourIframeId" with the id of your iframe element. You can adjust the degree value in the rotate() function to rotate the iframe by a different amount.