Αναζήτηση στην υποστήριξη

Προσοχή στις απάτες! Δεν θα σας ζητήσουμε ποτέ να καλέσετε ή να στείλετε μήνυμα σε κάποιον αριθμό τηλεφώνου ή να μοιραστείτε προσωπικά δεδομένα. Αναφέρετε τυχόν ύποπτη δραστηριότητα μέσω της επιλογής «Αναφορά κατάχρησης».

Learn More

Iframe immediately recreated

  • 3 απαντήσεις
  • 1 έχει αυτό το πρόβλημα
  • 38 προβολές
  • Τελευταία απάντηση από CzBiX

more options

https://jsfiddle.net/4cd3u0fL/1/

Steps to reproduce click the button

What is expected? Show text in iframe and output [true, true]

What is actually happening? iframe is empty, and output [true, false] in Firefox

This demo works in Chrome, but failed on Firefox v75-76.

https://jsfiddle.net/4cd3u0fL/1/ '''Steps to reproduce''' click the button '''What is expected?''' Show text in iframe and output [true, true] '''What is actually happening?''' iframe is empty, and output [true, false] in Firefox This demo works in Chrome, but failed on Firefox v75-76.

Επιλεγμένη λύση

@cor-el Thanks. Please have a look at this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=543435

If your PC is a little bit slow, you will see the iframe show content first, then changed to blank.

Ανάγνωση απάντησης σε πλαίσιο 👍 0

Όλες οι απαντήσεις (3)

more options
more options

In Firefox the result.insertAdjacentHTML immediately returns and doesn't wait until the iframe has been created. It works if I place the code in the timeout function.

function haha() {
  console.log('haha')
  const result = document.querySelector('#result')
  
  result.insertAdjacentHTML('beforebegin',  '<iframe id="iframe"></iframe>')
  
 setTimeout(() => {
 const el = document.querySelector('#iframe')
  const doc = el.contentDocument
  
  doc.body.innerHTML = 'Something'

result.innerHTML = [
      el === document.querySelector('#iframe'),
      doc === document.querySelector('#iframe').contentDocument, 
    ].join(',')
  }, 0)
}

const btn = document.querySelector('button')
btn.addEventListener('click', haha)

Τροποποιήθηκε στις από το χρήστη cor-el

more options

Επιλεγμένη λύση

@cor-el Thanks. Please have a look at this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=543435

If your PC is a little bit slow, you will see the iframe show content first, then changed to blank.