javascript - Unable to load and run bootstrap.js in an iframe -
for specific use case (some kind of demo of parts of full-page application inside other web-app) need load content html page iframe, apply css run js.
the loaded content uses bootstrap elements js. since there many different examples loaded, not want manually add bootstrap js , required css each loaded html snippet manually (which work) instead add per js once html loaded iframe.
what following: after making sure dom of html loaded iframe add css , necessary js follows:
$('#'+index+'-iframe-example').contents().find("head").append( '<link href="/app/static/css/app.css" rel="stylesheet" type="text/css" />' ); $('#'+index+'-iframe-example').contents().find("body").append( '<script src="/libs/jquery/dist/jquery.js"></script>' ); $('#'+index+'-iframe-example').contents().find("body").append( '<script src="/libs/bootstrap/dist/js/bootstrap.js"></script>' );
now problem: css loaded , content of iframe rendered correctly. js loaded , executed, elements in iframe not react should. if add js manually the html snippets, works.
Comments
Post a Comment