0

Is there a way to change a website's actual media queries through javascript ?

I'm developping an app contained in an iframe on my client's websites who recalculate body's width to place a panel in the right side. When the browser is resized, the client's media queries are called and act without taking my iframe into consideration resulting in a messed up layout.

Do you see a way for me to change the clients media queries with javascript so that I can keep the layout clean ?

Thanks for your help !

Raph
  • 374
  • 1
  • 16

2 Answers2

0

In this question there's an example of how load css files dynamicly with javascript. You could combine this with removing the original stylesheet via jquery, like:

$("link[rel='stylesheet']").remove()

and reload the same css file but with another media (your new media query).

Community
  • 1
  • 1
0

I found the answer here : https://stackoverflow.com/a/19593526/1324357 We can go to css with document.styleSheets.

Community
  • 1
  • 1
Raph
  • 374
  • 1
  • 16