How to rotate an iframe using javascript?

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

How to rotate an iframe using javascript?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by adan , 6 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.

Related Threads:

How to invoke a function in iframe using javascript?
How to pass credentials to iframe using javascript?
How to handle nested iframe using javascript?
How to delete html elements in an iframe using javascript?
How to wait for iframe content to load using only javascript?
How to rotate svg using d3.drag()?