Monday, February 26, 2024
 Popular · Latest · Hot · Upcoming
183
rated 0 times [  186] [ 3]  / answers: 1 / hits: 134332  / 11 Years ago, sat, january 5, 2013, 12:00:00

In the following snippet everything works as expected, but when I click Show Source Firefox produces this error:




--
[11:07:30.630] TypeError: document.getElementbyId is not a function @ http://localhost:8888/html5/native-rich-text.html:10


And Safari produces a similar error. What is causing this?





function showSource() {
var content = document.getElementbyId(edit).innerHTML
content.replace(/</g, '&lt;');
content.replace(/>/, '&gt: ');
prompt(Your Code:, content);

}

function createLink() {
var url = prompt(Enter URL:, http://);
if (url)
document.execCommand(createlink, false, url);
}

<h1>Native Rich Text</h1>
<p>No textboxes here, that's a &lt;div&gt; element!</p>
<div>
<input type=button value=Bold onclick=document.execCommand('bold', false, null);>
<input type=button value=Italic onclick=document.execCommand('italic', false, null);>
<input type=button value=Underline onclick=document.execCommand('underline', false, null);>
<input type=button value=Add Link onclick=createLink();>
<input type=button value=Show Source onclick=showSource();>
</div>
<div id=edit style=border:solid black; height: 300px; width: 400px; contenteditable=true>
Hello!
</div>




More From » html

 Answers
15

Case sensitive: document.getElementById (notice the capital B).


[#81065] Friday, January 4, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maxinec

Total Points: 117
Total Questions: 116
Total Answers: 116

Location: Bangladesh
Member since Sat, Jan 23, 2021
3 Years ago
maxinec questions
;