Related.. (HTML, JAVASCRIPT, Iframe)
I add code into Iframe's element using javascript(Dynamically.).
After I set all of things. JavaScript in Iframe doesn't work( onclick=functionName(defined inside iframe)... doesn't identify javascript function)
what's wrong...
this is my snippet.
//initialize
var destiframe = $('#tmpresult').contents();
destiframe.find('head').empty();
destiframe.find('body').empty();
//add script and style
destiframe.find('head').append("<style></style>");
destiframe.find('body').append('<script type="text/javascript"></script>');
//attach customized code
jQuery.each( code, function( i, code ) {
switch(i){
case 0:
destiframe.find('style').append(code.value);
break;
case 1:
destiframe.find('body').append(code.value);
break;
case 2:
destiframe.find('script').append(code.value);
break;
default:
console.log("empty set");
break;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…