Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.
-
jgiotta #1
Selected Text for Command UI Window
I'm creating my first Dreamweaver Custom Command. I want to use the selected
text in the document for JavaScript to wrap into a custom tag. However, I want
the Command UI input to value the selected text. Basically, if no text is
selected it just simply inserts the text entered from the input field, but if
there is text selected then I don't the input field to be empty.
jgiotta Guest
-
How to suppress popups of annotation andsticky note in a selected window?
I have opened several AVWindows for the same AVDoc and want to suppress (minimize) popups of annotation and sticky note in a certain window. The... -
Opening a Selected Tab in a new Window.
I have a TabBar object which is populated with a ViewStack, which consists of 7 different components (first code segment). What I want, is that when... -
How to get selected text from pdf using sdk
Hi, I am using following code in VB to get selected text from pdf. Dim jso As Object Dim gApp As Acrobat.CAcroApp Dim gPdDoc As... -
current selected text to highlighted text on mouse up event through java script
hi everybody, I want to convert the current selected text to highlighted text i.e. to yellow background on mouse up event on pdf form through... -
How to get selected text using IAC API?
In fact i need this: after user selects text (or rectangular part of pdf documents content) i have to be able to get page number and coordinates of... -
danilocelic *TMM* #2
Re: Selected Text for Command UI Window
jgiotta wrote:
To get the user's selection you can use the following code:> I'm creating my first Dreamweaver Custom Command. I want to use the selected
> text in the document for JavaScript to wrap into a custom tag. However, I want
> the Command UI input to value the selected text. Basically, if no text is
> selected it just simply inserts the text entered from the input field, but if
> there is text selected then I don't the input field to be empty.
var dom = dw.getDocumentDOM()
var sel = dom.getSelection();
var html = dom.documentElement.outerHTML;
// see what the selection is
// can use this to set the value of your text field.
alert(html.substring(sel[0],sel[1]));
But you can test the offsets within sel to see if there is anything
selected. If sel[0] and sel[1] are equal then there is nothing selected,
there is only an insertion point.
--
Danilo Celic
| Extending Knowledge Daily : [url]http://CommunityMX.com/[/url]
| Team Macromedia for Dreamweaver : [url]http://macromedia.com/go/team/[/url]
danilocelic *TMM* Guest
-
jgiotta #3
Re: Selected Text for Command UI Window
I figured out a solution. In the HTML document for the UI, I added a onLoad
event to the body tag. It grabs the selected text and populates the input
field. Example:
function myValue(input) {
var theDOM = dw.getDocumentDOM();
var theDocEl = theDOM.documentElement;
var theWholeDoc = theDocEl.outerHTML;
var theSelNode = theDOM.getSelectedNode();
var theSel = theDOM.getSelection();
var selText = theWholeDoc.substring(theSel[0],theSel[1]);
input.value = selText;
}
jgiotta Guest



Reply With Quote

