mercredi 17 septembre 2014

span tags applied by javascript


Vote count:

0




i am working on a text editor in html and js that opens by the context menu.


When the user highlights some text and right clicks a custom menu opens up with the various text format options.


http://ift.tt/XHZRnF


this is the main format function



function StyleChange(style,property) {
var span = document.createElement("span");
span.style[style] = property;

if (window.getSelection) {
var sel = window.getSelection();
if (sel.rangeCount) {
var range = sel.getRangeAt(0).cloneRange();
range.surroundContents(span);
sel.removeAllRanges();
sel.addRange(range);
}
}
}


i am having a couple of problems at the minute with a few little things. is there a way to get it to recognise if there is a span already there as if a user changes the text colour to yellow and the changes his mind it wont let him select any other colour same goes for when trying the use the high light function.


if you making loads of customisations to the text id colour:orange; background:yellow; font-weight:bold; you end up with span within span and it looks messy.


Any ideas?



asked 31 secs ago







span tags applied by javascript

Aucun commentaire:

Enregistrer un commentaire