Thursday, October 25, 2007

innerText and textContent

Try to use your HTML text/code for your confirm dialog message, below is my sample.

document.getElementById("msg").innerText is perfect for IE, but Firefox.

document.getElementById("msg").textContent works for Firefox, but loses all line breaks.

So I come out my solution :

<div style="display: none; visibility: hidden;" id="msg">
Deleting this category will lose all articles.
Do you really want to do it?</div>

function confirmDeletion() {
var msg = document.getElementById("msg").innerHTML.replace(/
if (confirm(msg) ) {
return false;

No comments: