js画图开发库--mxgraph--[offpage-关闭页面(页面更新).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> <!-- 如果本文件的包与src不是在同一个目录,就要将basepath设置到src目录下 --> <script type="text/javascript"> mxBasePath = '../src'; </script> <!-- 引入支持库文件 --> <script type="text/javascript" src="../src/js/mxClient.js"></script> <!-- 示例代码 --> <script type="text/javascript"> // 高亮显示完整单元 mxConstants.ACTIVE_REGION = 1; // 程序在此方法中启动 function main() { // 检查浏览器支持 if (!mxClient.isBrowserSupported()) { mxUtils.error('Browser is not supported!', 200, false); } else { var container = document.createElement('div'); container.style.position = 'absolute'; container.style.overflow = 'hidden'; container.style.left = '0px'; container.style.top = '0px'; container.style.right = '0px'; container.style.bottom = '0px'; container.style.background = 'url("editors/images/grid.gif")'; // 增加IE忽略的样式 if (mxClient.IS_QUIRKS) { document.body.style.overflow = 'hidden'; new mxDivResizer(container); } document.body.appendChild(container); // 在容器中创建图形 var graph = new mxGraph(container); graph.setEnabled(false); // 关闭页面连接线的亮点 var highlight = new mxCellTracker(graph, null, function(me) { var cell = me.getCell(); if (cell != null && cell.value != null && typeof(cell.value.create) == 'function') { return cell; } return null; }); // 添加点击按钮的处理事件 graph.addListener(mxEvent.CLICK, function(source, evt) { var cell = evt.getProperty('cell'); if (cell != null && cell.value != null && typeof(cell.value.create) == 'function') { cell.value.create(); } }); // 添加点击按钮的处理事件 graph.getCursorForCell = function(cell) { if (cell != null && cell.value != null && typeof(cell.value.create) == 'function') { return 'pointer'; } }; // 获取父元素插入子元素中 var first = null; var second = null; first = function() { var value = {toString: function() { return 'Next'; }, create: second}; // 开始更新事务 graph.getModel().beginUpdate(); try { graph.getModel().setRoot(graph.getModel().createRoot()); var parent = graph.getDefaultParent(); var v1 = graph.insertVertex(parent, null, 'Click', 30, 20, 80, 30, 'fillColor=#FFFF88;strokeColor=#FF1A00'); var v2 = graph.insertVertex(parent, null, 'Next', 20, 150, 100, 30, 'fillColor=#FFFF88;strokeColor=#FF1A00'); var v3 = graph.insertVertex(parent, null, value, 200, 150, 40, 40, 'shape=triangle;align=left;fillColor=#C3D9FF;strokeColor=#4096EE'); var e1 = graph.insertEdge(parent, null, null, v1, v2, 'strokeColor=#FF1A00'); } finally { // 结束更新事务 graph.getModel().endUpdate(); } }; second = function() { var value = {toString: function() { return 'Prev'; }, create: first}; // 开启更新事务 graph.getModel().beginUpdate(); try { graph.getModel().setRoot(graph.getModel().createRoot()); var parent = graph.getDefaultParent(); var v1 = graph.insertVertex(parent, null, 'Click', 30, 20, 80, 30, 'fillColor=#CDEB8B;strokeColor=#008C00'); var v2 = graph.insertVertex(parent, null, 'Prev', 220, 20, 100, 30, 'fillColor=#CDEB8B;strokeColor=#008C00'); var v3 = graph.insertVertex(parent, null, value, 30, 150, 40, 40, 'shape=triangle;align=right;fillColor=#C3D9FF;strokeColor=#4096EE;direction=west'); var e1 = graph.insertEdge(parent, null, null, v1, v2, 'strokeColor=#008C00'); } finally { // 结束更新事务 graph.getModel().endUpdate(); } }; first(); } }; </script> </head> <!-- 页面载入时启动程序 --> <body onload="main();"> </body> </html>