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
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: '
@Teemu oh .. Capisco .. ma la domanda rimane ancora. Ho creato un'inframe con javascript e posso aggiungere elementi a iframe usando javascript. c'è un modo per aggiungere doctype? –
Se vuoi dire che veramente "document.write()" alcuni elementi tra tag body nel tuo codice, e possono anche essere visti nell 'iframe, questa domanda sarebbe al di là delle mie conoscenze:). – Teemu