Skip to content

Instantly share code, notes, and snippets.

@ps-team
Created October 27, 2017 10:07
Show Gist options
  • Save ps-team/e70337ed5a5fcc281c3abca00a7c8b96 to your computer and use it in GitHub Desktop.
Save ps-team/e70337ed5a5fcc281c3abca00a7c8b96 to your computer and use it in GitHub Desktop.
Append stylesheet to iframe contents (e.g. Twitter widget) - this is filthy, but it works well when no other option is available.
$(document).ready(function(){
setTimeout(function() {
var iframe = document.getElementsByTagName('iframe')[0],
iframeDoc = iframe.contentWindow.document;
var otherhead = iframeDoc.getElementsByTagName("head")[0];
var css = document.createElement("link");
css.type = "text/css";
css.rel = "stylesheet";
css.href = "/SiteElements/Stylesheets/twitter-widget.css";
otherhead.appendChild(css);
}, 500);
});
@audacitus
Copy link

From the depths of the internet, and on behalf of others who learnt from this without saying anything, thank you.

@contexua
Copy link

I would like to say thanks also... saved a lot of time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment