Styling inside an iframe?

This would be kind of cool if it works. I don't really have a need for something like this right now but it would probably be fun to play with.

1
2
3
4
5
6
7
8
9
window.onload = function(){
  var iFrameDoc = document.frames['my_iframe'].document;
  var newElem = iFrameDoc.createElement("link");
  newElem.rel="stylesheet";
  newElem.type="text/css";
  newElem.href = "https://www.blah.com/" + parent.document.styleSheets[2].href;
  iFrameDoc.documentElement.childNodes[1].childNodes[0].appendChild(newElem);
  //alert(iFrameDoc.documentElement.childNodes[1].childNodes[0].innerHTML);
}

From css for an iframe at Coderanch.
 

Comments