WebOffice文档控件常见问题
function AddPicture()
{
WebOffice = document.getElementById('WebOffice');
var doc = WebOffice.ActiveDocument;
doc.Shapes.AddPicture(
"c:\\我的文档\\My Pictures\\test.gif",
false,true);
doc.Shapes(doc.Shapes.Count).Select();
var range = doc.Application.Selection.ShapeRange;
range.WrapFormat.Type = 3;
range.PictureFormat.TransparentBackground = true;
range.PictureFormat.TransparencyColor = 0xFFFFFF;
range.Fill.Visible = false;
}
WebOffice = document.getElementById('WebOffice');
WebOffice.ActiveDocument.Application.Dialogs(163).Show()。
//也可以使用:
WebOffice = document.getElementById('WebOffice');
WebOffice.WebDialogs(163)
function keyDown(e){
e.preventDefault();
var currKey=0, e=e||event||window.event;
currKey = e.keyCode||e.which||e.charCode;
if(currKey == 83 && (e.ctrlKey||e.metaKey)){
//这里加入控件保存的接口JS代码
}
}
document.onkeydown = keyDown;
<div style="position:absolute;z-index=1;">
<iframe src='about:blank' frameBorder='0' marginHeight='0' marginWidth='0' style='position: absolute; visibility: inherit; top: 0px; left: 0px; width: 100%; height: 100%; z-index: -1; filter: alpha(opacity = 0);'></iframe>
<!-- 此处可以放需要展示在OCX控件之上的代码(菜单栏),如果存在多处则需要添加多个-->
</div>
function isUnloadJs() //isUnloadJs函数是智能窗退出时自动响应执行。
{
if(confirm('是否真的关闭本窗口?'))
{
//这里写你的JS代码逻辑
alert("任务完成!");
}else{
isExit = 0;//isExit为固定变量用于与智能窗交互,当值为0时,表示不关闭本窗口
}
}
function allRevisions() {
try{
var RevCount;
RevCount = document.getElementById('WebOffice').GetRevCount();
alert("共有"+RevCount+"修订痕迹");
for(var i=1; i<= RevCount; i++)
{
chrOper = document.getElementById('WebOffice').GetRevInfo(i,2);
if("1" == chrOper){
chrOper = "插入";
}else if("2" == chrOper){
chrOper = "删除";
}else{
chrOper = "设置格式";
}
editDate = new String(document.getElementById('WebOffice').GetRevInfo(i,1));
alert(editDate + " 用户:"+document.getElementById('WebOffice').GetRevInfo(i,0) + "\r\n操作:" + chrOper + "\r\n内容:" + document.getElementById('WebOffice').GetRevInfo(i,3));
}
}catch(e){
alert("信息提示:\r\n出错内容:"+e+"\r\n错误代码:"+e.number+"\r\n错误描述:"+e.description);
}
}
// 设置指定的Sheet为当前显示的Sheet
function showSheet(sheetName) {
var sMac = "function myfunc()" + "\r\n"
+ "Application.Sheets(\""+ sheetName +"\").Select \r\n"
+ "End function";
document.getElementById("WebOffice").RunMacro("myfunc", sMac);
}
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome]
"ExternalProtocolDialogShowAlwaysOpenCheckbox"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge]
"ExternalProtocolDialogShowAlwaysOpenCheckbox"=dword:00000001
window.console = window.console || (function () {
var c ={};
c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile= c.clear = c.exception = c.trace = c.assert = function(){};
return c;
})();
WebOffice.Titlebar=false;
WebOffice.MenuBar=false;
WebOffice.Toolbars=false;
WebOffice.IsNotCopy=1;
WebOffice.ProtectDoc(1,2,'123');