JQuery add css link in iframe head

I am trying to add a css file to an iframe that is being created on a page from a global script. I can access part of it, but for some reason I cannot add it to my head. This also does not throw mistakes, which disappoints.

<script type="text/javascript"> $(document).ready(function() { $('#outline_text_ifr') .contents() .find('head') .append('<link type="text/css" rel="stylesheet" href="/include/outline.css" media="all" />'); }); </script> 
+4
source share
1 answer
 var $head = $("#IFrame").contents().find("head"); var url = "Styles/styles.css"; $head.append($("<link/>", { rel: "stylesheet", href: url, type: "text/css" } )); 

or

  $('#IFrame').contents().find('#div1').css({ color: 'purple' }); 
+8
source

Source: https://habr.com/ru/post/1334106/


All Articles