1.OnRButtonDown.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>三维地图上的右键菜单实现示例</title>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<script type="text/javascript">
var bm = 0;
function StartF(value) {
try {
var sg = CreateSGObj();
sg.AttachEvent("OnRButtonDown", OnRButtonDown);
bm = value;
}
catch (e) {
alert(e);
}
} function EndF() {
try
{
var sg = CreateSGObj();
sg.DetachEvent("OnRButtonDown", OnRButtonDown);
sg.Window.RemovePopupByCaption("右键菜单");
var pif = window.document.getElementById("RC");
pif.style.display = "none";
}
catch (e)
{ }
} function OnRButtonDown(Flags, X, Y) {
try
{
if (bm == 0) {
var sg = CreateSGObj();
var pp = sg.Creator.CreatePopupMessage("右键菜单", "http://localhost:4319/Coding/sgw66/SGWorld/RC.html", X, Y, 100, 200, -1);
pp.ShowCaption = false;
pp.Flags = 128 + 4;
sg.Window.ShowPopup(pp);
}
else {
var pif = window.document.getElementById("RC");
pif.style.display = "";
pif.style.top = Y;
pif.style.left = X;
pif.style.width = 100; }
return true;
}
catch (e)
{ } return false; } //------------------------------------------------------------
// 创建sgworld对象 赵贺 2015.06.09. TEPro6.6
//------------------------------------------------------------
function CreateSGObj() {
var obj = $("sgworld");
if (obj == null) {
obj = document.createElement('object');
document.body.appendChild(obj);
obj.name = "sgworld";
obj.id = "sgworld";
obj.classid = "CLSID:3A4F9199-65a8-11d5-85c1-0001023952c1";
}
return obj;
}
function $(id) {
return window.document.getElementById(id);
}
</script>
</head>
<body>
<input id="Button1" type="button" value="Popup" onclick="StartF(0)" />
<input id="Button3" type="button" value="IFrame" onclick="StartF(1)" />
<input id="Button2" type="button" value="结束" onclick="EndF()" />
<div id="res"></div>
<iframe id ="RC" style="position:absolute; width:100px; height:200px; display:none;" src="RC.html"></iframe>
<object id="TerraExplorer3DWindow" classid="CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1" style="width:800px;height:600px;"></object>
<object id="TerraExplorerInformationWindow" classid="CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1" style="width:300px;height:600px;"></object>
</body>
</html>
2.RC.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script>
document.oncontextmenu = function () { return false; };
</script>
</head>
<body>
<table>
<tr><td>选项一</td></tr>
<tr><td>选项二</td></tr>
<tr><td><select id="Select1">
<option>选项三</option>
<option>选项四</option>
<option>选项五</option>
<option>选项六</option>
<option>选项七</option>
<option>选项三</option>
<option>选项四</option>
<option>选项五</option>
<option>选项六</option>
<option>选项七</option>
<option>选项三</option>
<option>选项四</option>
<option>选项五</option>
<option>选项六</option>
<option>选项七</option>
</select></td></tr>
<tr><td>
<input id="Button1" type="button" value="button" onclick="window.parent.document.getElementById('RC').style.width = 500;" /></td></tr>
</table>
</body>
</html>