I have been struggling this basic simple functionality for days and
appreciate if you can give me some answer/pointers.
My objective is to insert certain text string in a textfield
area(similar as pop-up menu does 'Paste' - but not by 'Copy'), so I
created a menuitem in popup and did oncommand=document.write()
( or document.writeln() ) but this does not work. How do I do this?
Thanks a bunch!
-Shanya
document.getElementById("myTB").value = "hello"
Thanks again.
Shanya
> Perhaps I did not explain it clearly. What I want do is this. In any
> textfield of the any web page, when I right click I would have a popup
> menuitem call it 'Insert String', so when you select submenu such as
> 'Insert Hello', it will write 'Hello' string.(e.g. textfield of serach
> widget).
Shanya,
You can easily do this by using Firefox's gContextMenu object as follows:
gContextMenu.target.value = "Hello";
- Soyapi
--
Soyapi Mumba
soyapi.blogspot.com
searchwith.mozdev.org
I appreciate your help in this matter. Per your guidance, I created
test.xlu as you mentioned in your last reply, however there is still
something I am missing and it is not working. Please help.
Thanks,
-Shanya
------------------------------------------- test.xlu
------------------------
<?xml version="1.0"?>
<overlay id="sample"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript"
src="chrome://test/content/test.js"/>
<statusbar id="status-bar">
<statusbarpanel id="my-panel" label="Welcome, Mayank Thakore!"/>
<button id="find-button" label="Find" tooltiptext="Click here to do
NOTHING!!"/>
</statusbar>
<popup id="contentAreaContextMenu">
<menuseparator id="insertstr-context-separator"/>
<menu label="Insert String" id="insertstr-context">
<menupopup onpopupshowing="displayIfDetectTextarea(this)">
<menuitem label="3Ws" id="insertstr-3ws-context"
oncommand="alert('Button was pressed!');"/>
<menuitem label="CF2C" id="insertstr-cf2c-context"
oncommand="str_parse1(this, 'Comment To Collaborator')"/>
<menuitem label="Last Note" id="insertstr-lastnote-context"
oncommand="str_parse('LastNotes')"/>
<menuitem label="Somethig else" id="insertstr-se-context"
oncommand="str_parse('SomethingElse')"/>
</menupopup>
</menu>
</popup>
<script>
function str_parse1(idName, str) {
document.getElementById( idName.id )..value = str;
}
</script>
</overlay>
---------------------------------
Thanks
Shanya
Thanks. This works at some extent, however it replaces string not
inserts. Means it wipes out the existing text and replaces with the
string and that is not what I want. I need to just insert, such as
signature at the end.
Thanks,
Sanaya
gContextMenu.target.value += "Hello";
Thanks, that worked! Hope this function will not be deprecated or
changed :)
Shanya