Ein Skript in den Header eines iFrames einfügen, ohne den Hauptteil des iFrames zu löschen

Ich möchte ein Skript zum Header eines iFrames hinzufügen, ohne dabei alles zu verlieren, was im Body oder Header des iFrames enthalten ist ...

hier ist das, was ich gerade habe, das den iFrame mit dem neuen Skript aktualisiert, aber es löscht alles im iframe heraus und hängt nicht an, was ich möchte. Danke! B

    // Find the iFrame
    var iframe = document.getElementById('hi-world');

    // create a string to use as a new document object
    var val = '<scr' + 'ipt type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></scr' + 'ipt>';

    // get a handle on the <iframe>d document (in a cross-browser way)
    var doc = iframe.contentWindow || iframe.contentDocument;
    if (doc.document) { doc = doc.document;}

    // open, write content to, and close the document
    doc.open();
    doc.write(val);
    doc.close();

Antworten auf die Frage(1)

Ihre Antwort auf die Frage