Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Javascript] Iframe Inhalt aus Feld zuweisen

Empfohlene Antworten

Veröffentlicht

Hallo Members!

ich habe einen Iframe in einem document und möchte diesem per Javascript

den Inhalt eines Feldes zuweisen. Wie funktioniert das?

Ich kann ja den Inhalt des Iframes mit z.B:

this.iframe.document.body.innerHTML

oder

this.iframe.document.body.innerTEXT

abfragen. Wie aber setze ich den Inhalt?

?!?!


this.iframe.document.body.innerHTML = "<h1>TESTTEXT</h1>";

// oder

this.iframe.document.body.innerTEXT = "<h1>TESTTEXT</h1>";

Also wenn ich direkt automatisch per Javascript.

this.iframe.document.body.innerHTML = 'XYZ';

ausführen lasse, dann geht das nicht.

Führe ich dies per Klick auf einen Link (nicht automatisch)aus, dann gehts..

Wieso das denn?

Habs soeben rausgefunden:

Wenn ich das in eine Function setze, dann gehts:

function document.onreadystatechange(){

this.iframe.document.body.innerHTML = 'XYZ';

}

Wieso das denn?

Ich denke das das ein "Sicherheitsfeature" sein soll!?

hast du die function extra als methode in das document Object implementiert?

Ich habe die Funktion einfach in das Document eingebunden, in das der IFrame integriert ist.

Jetzt habe ich aber noche ine andere Frage:

Man kann ja in einen IFrame z.B. links einfügen. Das geht dann mit:

iframe.document.execCommand('createlink', true, null);

Wie aber kann eine Tabelle über execCommand einfügen?

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.