是否有支持获得和确定治疗者立场的 j印本?
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
是否有支持获得和确定治疗者立场的 j印本?
我拿不出详细情况的解释,但这项工作将:
function getTextNodesIn(node) {
var textNodes = [];
if (node.nodeType == 3) {
textNodes.push(node);
} else {
var children = node.childNodes;
for (var i = 0, len = children.length; i < len; ++i) {
textNodes.push.apply(textNodes, getTextNodesIn(children[i]));
}
}
return textNodes;
}
function setSelectionRange(el, start, end) {
if (document.createRange && window.getSelection) {
var range = document.createRange();
range.selectNodeContents(el);
var textNodes = getTextNodesIn(el);
var foundStart = false;
var charCount = 0, endCharCount;
for (var i = 0, textNode; textNode = textNodes[i++]; ) {
endCharCount = charCount + textNode.length;
if (!foundStart && start >= charCount && (start < endCharCount || (start == endCharCount && i < textNodes.length))) {
range.setStart(textNode, start - charCount);
foundStart = true;
}
if (foundStart && end <= endCharCount) {
range.setEnd(textNode, end - charCount);
break;
}
charCount = endCharCount;
}
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
} else if (document.selection && document.body.createTextRange) {
var textRange = document.body.createTextRange();
textRange.moveToElementText(el);
textRange.collapse(true);
textRange.moveEnd( character , end);
textRange.moveStart( character , start);
textRange.select();
}
}
Now you just get your element and select stuff:
setSelectionRange(document.getElementById( dijitEditorBody ), 10, 50);
是,redactor.js 正在这样做:
$(#redactor ).redactor ( setCaret , elements, 4);
我正在寻找一种解决办法。 编辑并接过这个老问题。 这里是我这样做的方法(它把二jit/_editor/EnterKeyHandling plugin推向一滴)。
我创造了我自己的美好生活:
define([
"dojo/_base/declare",
"dijit/_editor/_Plugin",
"dijit/_editor/range",
"dijit/_editor/selection"
], function(declare, _Plugin, rangeapi, selectionapi) {
var MyPlugin = declare(_Plugin, {
setToolbar: function(editorToolbar){
// [...]
this.own(this.editor.on( keypressed , lang.hitch(this, onKeyPressed )));
},
onKeyPressed: function(){
// summary:
// Handler for after the user has pressed a key, and the display has been updated.
var block = undefined,
blockNode = undefined,
selection = rangeapi.getSelection(this.editor.window),
range = selection.getRangeAt(0);
if(!range.collapsed){
range.deleteContents();
selection = rangeapi.getSelection(this.editor.window);
range = selection.getRangeAt(0);
}
block = rangeapi.getBlockAncestor(range.endContainer, null, this.editor.editNode);
if (block.blockNode) {
blockNode = block.blockNode;
// this is the node under the cursor...
console.debug(blockNode);
}
});
_Plugin.registry["myplugin"] = _Plugin.registry["myplugin"] = function(args){
return new MyPlugin();
};
return MyPlugin;
});
然后,在你本人的不动产/业主的“外来财产”中添加“米普林”。
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...
I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...
Is it possible for someone to give me a few pointers on how to display a multidimensional array in the form of a bar graph? The array is multidimensional, with three elements in each part - and the ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.