私はJavaScriptで質問があります 私はユーザーの選択(ハイライトされたテキスト)をループし、trlまたはltrからテキストの方向を変更する必要があります。ここ は私がやった:強調表示されたテキストをループします。
this._execCom("FormatBlock",'<div>');
var node = null;
if (this.area.contentWindow.getSelection) {
node = this.area.contentWindow.getSelection().anchorNode.parentNode;
}
else if (this.area.contentWindow.document.selection) {
var range = this.area.contentWindow.document.selection.createRange();
if (range) {
node = range.parentElement();
}
var walker=this.area.contentWindow.document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, null, false);
while (walker.nextNode())
{
x=walker.currentNode.tagName;
if(x == 'DIV')
walker.currentNode.style.direction="ltr";
}
これは、彼らが強調表示されたテキストまたはしない範囲内であり、私は変更が唯一のユーザーの選択に行われる必要がある場合でも、すべてのdivのための方向を変えます。
お願いします。
多くのお礼ありがとうございます
あなたは*フル*コードスニペットを表示することができますか?このコードは、一貫性のないブレース、一貫性のないインデント、そして何がポストされているかによってわかるように、宣言されていない変数を暗黙的なグローバル変数とする混乱です。 –
- 地獄です。 – mowwwalker
これが見つかりました:http://stackoverflow.com/questions/3454152/cross-browser-selection-range-library – mowwwalker