<script type="text/javascript">
// Get the window object where the context menu was opened.
var oWindow = window.external.menuArguments; // 获取window元素
// Get the document object exposed through oWindow.
var oDocument = oWindow.document; // 获取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>