Jquery getscript for iframe object

I have a dynamically created iframe that I am trying to add a script to. For example:

var iframe = document.createElement ("iframe");

I would like to add javascript to this iframe. It works for me without using jquery, creating a script element under the iframe object and adding callbacks to this script object through readystate and onReadyState events. Now I would like to try the same with jquery.

However, if I just do:

$.getScript(url,function() {
 myCallback();
});

My scripts are added to the current document, and links from the iframe object are broken. How can I call getcript for iframe object?

Tried this, which did not work:

var elementID = $(element).attr('id');
$('iframe#' + elementID).getScript(url, function(){
 myCallback();
}); 
+3
source share
1 answer

.getScript , iframe, jquery script document

0

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


All Articles