DHTML Object Properties DHTML Objects
Returns the window object where the context menu item was executed.
HTML |
N/A |
Script |
window.external.menuArguments [ = oWindow ] |
vVariables |
Reference to the window object where the context menu was opened. |
The property is read-only with no default value.
This property is only accessibly through script specified in the registry for a new context menu entry.
The menuArguments property returns an object reference of the window where the context menu was opened. The event object is exposed through this object reference, allowing authors to query the srcElement, clientX, and clientY properties.
See Extending the Dynamic HTML Object Model for more information on how to implement extensions to the DHTML object model, and Adding Entries to the Standard Context Menu for more information on how to add an entry into the standard context menus in Internet Explorer.
The following sample demonstrates the use of the
menuArguments property. This sample changes selected text to uppercase, or inserts text if nothing was selected.
<script LANGUAGE = "JavaScript">
// Get the window object where the
// context menu was opened.
var oWindow = window.external.menuArguments;
// Get the document object exposed through oWindow.
var oDocument = oWindow.document;
// Get the selection from oDocument.
// in oDocument.
var oSelect = oDocument.selection;
// Create a TextRange from oSelect.
var oSelectRange = oSelect.createRange ( );
// Get the text of the selection.
var sNewText = oSelectRange.text;
// If nothing was selected, insert some text.
if ( sNewText.length == 0 ) {
oSelectRange.text = "INSERT TEXT";
}
// Otherwise, convert the selection to uppercase.
else{
oSelectRange.text = sNewText.toUpperCase ( );
}
</script>
external
Adding Entries to the Standard Context Menu, Extending the Dynamic HTML Object Model