2013-01-06 11 views
5

Sto costruendo un widget che può essere incorporato in altri siti. Il widget è un iframe creato utilizzando document.write() tuttavia non so come applicare il doctype iframe utilizzando javascript.javascript creare un iframe con strict doctype

Ecco il mio codice:

document.write("<iframe scrolling=\"no\" frameborder=\"0\">"); 
document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"); 
document.write("<html>"); 
document.write("<head></head><body></body>"); 
document.write("</html>"); 
document.write("</iframe>"); 
document.write("</div>"); 

L'IFRAME viene creata, ma il doctype non viene applicata. c'è un modo per farlo?

Grazie

+1

Ho paura che questo non funzioni davvero. Tutti gli elementi tra i tag 'iframe' si trovano nella pagina originale e sono mostrati, se il browser non supporta iframe. Quello che ottieni con questo codice è solo un iframe con 'src =" about: blank "'. Per favore controlla questo: [MDN: '