•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,667 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,943 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 669 | Replies: 0
![]() |
•
•
Join Date: Oct 2007
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
I need help figuring this out. I have a "contenteditable" div. I have a menu that does the basics, bold, italic, etc. I need to add custom tags that will be represented in the source, not visually. In other words, when I use the code below:
Which is triggered by:
It surrounds the selected text as it should, but in the source it looks like:
Instead of:
Visually, in the editable div, it looks like the above, but I need it to be tags in the source, not visible on the surface.
Am I making any sense?
Any help would be appreciated.
Thanks.
function myCustomTag(v) {
var str = document.selection.createRange().text;
document.getElementById("editor").focus();
var sel = document.selection.createRange();
sel.text = "<" + v + ">" + str + "</" + v + ">";
return;
}Which is triggered by:
onClick="myCustomTag('myTag');"It surrounds the selected text as it should, but in the source it looks like:
<myTag>surrounded text<myTag>Instead of:
<myTag>surrounded text</myTag>Visually, in the editable div, it looks like the above, but I need it to be tags in the source, not visible on the surface.
Am I making any sense?
Any help would be appreciated.
Thanks.
Last edited by webopolis : Feb 16th, 2008 at 4:15 pm.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- Previous Thread: Cross-Browser setTimeout Problem
- Next Thread: How to capture window events in javascript


Linear Mode