Join us and the lead editor of IRL, Mozilla's multi-award-winning podcast, for a behind-the-scenes look at the pod and to contribute your ideas for the next season, themed: "AI and ME." Mark your calendar and join our Community Call on Wednesday, Aug 7, 17:00–17:45 UTC. See you there!

Zoeken in Support

Vermijd ondersteuningsscams. We zullen u nooit vragen een telefoonnummer te bellen, er een sms naar te sturen of persoonlijke gegevens te delen. Meld verdachte activiteit met de optie ‘Misbruik melden’.

Meer info

Deze conversatie is gearchiveerd. Stel een nieuwe vraag als u hulp nodig hebt.

document.execCommand("formatBlock", false, "H1") is splitting the editable span

  • 1 antwoord
  • 5 hebben dit probleem
  • 5 weergaven
  • Laatste antwoord van John99

more options

document.execCommand("formatBlock", false, "H1") is splitting the editable span. I have the following html...


<span  style="border: 2px solid rgb(180, 199, 223); padding: 0px;" contentEditable="true">

 <div>
  <span>
   Try this.
   Try this.

  </span>
 </div>

 <div>Tathagata Roy </div>

</span>


Now I selected "Roy" and used document.execCommand("formatBlock", false, "H1") and the HTML becomes like following

<span style="border: 2px solid rgb(180, 199, 223); padding: 0px;" contenteditable="true">
 <div>
  <span>
   Try this.
   Try this.
  </span>
 </div>
</span>
<h1>
<span style="border: 2px solid rgb(180, 199, 223); padding: 0px;" contenteditable="true">
 <div>
  Tathagata Roy 
 </div>
</span>
</h1>
<span style="border: 2px solid rgb(180, 199, 223); padding: 0px;" contenteditable="true">

</span>
</span>


So it's splitting into three editable spans. But other browsers like chrome/IE are giving output like following

<div>
  <span>
   Try this.
   Try this.
  </span>
 </div>

 <h1>Tathagata Roy</h1>  


So it's replacing it's enclosing div and replacing it by

. This is what I expected.

document.execCommand("formatBlock", false, "H1") is splitting the editable span. I have the following html... <pre><nowiki><span style="border: 2px solid rgb(180, 199, 223); padding: 0px;" contentEditable="true"> <div> <span> Try this. Try this. </span> </div> <div>Tathagata Roy </div> </span> </nowiki></pre> Now I selected "Roy" and used document.execCommand("formatBlock", false, "H1") and the HTML becomes like following <pre><nowiki><span style="border: 2px solid rgb(180, 199, 223); padding: 0px;" contenteditable="true"> <div> <span> Try this. Try this. </span> </div> </span> <h1> <span style="border: 2px solid rgb(180, 199, 223); padding: 0px;" contenteditable="true"> <div> Tathagata Roy </div> </span> </h1> <span style="border: 2px solid rgb(180, 199, 223); padding: 0px;" contenteditable="true"> </span> </span> </nowiki></pre> So it's splitting into three editable spans. But other browsers like chrome/IE are giving output like following<br /> <br /> <pre><nowiki><div> <span> Try this. Try this. </span> </div> <h1>Tathagata Roy</h1> </nowiki></pre> So it's replacing it's enclosing div and replacing it by <h1>. This is what I expected.

Bewerkt door cor-el op

Alle antwoorden (1)

more options

You would probably get an answer in another forum, maybe try one of the Mozillazine forums if it is an enquiry about coding and use of a website. Possibly try : http://forums.mozillazine.org/viewforum.php?f=25

In the unlikely event that it is due to a fault with Firefox then a bug will need to be filed.

Bewerkt door John99 op