Pre-preparation work:
1, download demo source, and upgrade to the latest version (jquery 1.7.2,easyui 1.2.6), direct replacement can be, upgrade Easyui is to be the CSS JS theme replace All
2, in the first page of the HTML code: will
Copy Code code as follows:
<div id= "MM" class= "Easyui-menu" style= "width:150px"; >
<div id= "mm-tabupdate" > Refresh </div>
<div class= "Menu-sep" ></div>
<div id= "Mm-tabclose" > Shutdown </div>
<div id= "Mm-tabcloseall" > All close </div>
<div id= "Mm-tabcloseother" > all except Close </div>
<div class= "Menu-sep" ></div>
<div id= "Mm-tabcloseright" > right of the current page all closed </div>
<div id= "Mm-tabcloseleft" > The left of the current page all closed </div>
<div class= "Menu-sep" ></div>
<div id= "Mm-exit" > Exit </div>
</div>
To
Copy Code code as follows:
<div id= "MM" class= "Easyui-menu" style= "width:150px"; >
<div id= "Refresh" > Refresh </div>
<div class= "Menu-sep" ></div>
<div id= "Close" > Shutdown </div>
<div id= "CloseAll" > All close </div>
<div id= "Closeother" > all except Close </div>
<div class= "Menu-sep" ></div>
<div id= "Closeright" > right of the current page all closed </div>
<div id= "Closeleft" > The left of the current page all closed </div>
<div class= "Menu-sep" ></div>
<div id= "Exit" > Exit </div>
</div>
Add a new method to the Outlook2.js as follows:
Copy Code code as follows:
function Closetab (action)
{
var alltabs = $ (' #tabs '). Tabs (' tabs ');
var currenttab =$ (' #tabs '). Tabs (' getselected ');
var alltabtitle = [];
$.each (Alltabs,function (i,n) {
Alltabtitle.push ($ (N). Panel (' Options '). title);
})
Switch (action) {
Case "Refresh":
var iframe = $ (currenttab.panel (' Options '). Content);
var src = iframe.attr (' src ');
$ (' #tabs '). Tabs (' Update '), {
Tab:currenttab,
Options: {
Content:createframe (SRC)
}
})
Break
Case "Close":
var currtab_title = currenttab.panel (' Options '). title;
$ (' #tabs '). Tabs (' Close ', currtab_title);
Break
Case "CloseAll":
$.each (Alltabtitle, function (i, n) {
if (n!= onlyopentitle) {
$ (' #tabs '). Tabs (' Close ', n);
}
});
Break
Case "Closeother":
var currtab_title = currenttab.panel (' Options '). title;
$.each (Alltabtitle, function (i, n) {
if (n!= currtab_title && n!= onlyopentitle)
{
$ (' #tabs '). Tabs (' Close ', n);
}
});
Break
Case "Closeright":
var TabIndex = $ (' #tabs '). Tabs (' Gettabindex ', currenttab);
if (TabIndex = = alltabs.length-1) {
Alert (' Pro, behind No ^@^!! ');
return false;
}
$.each (Alltabtitle, function (i, n) {
if (i > TabIndex) {
if (n!= onlyopentitle) {
$ (' #tabs '). Tabs (' Close ', n);
}
}
});
Break
Case "Closeleft":
var TabIndex = $ (' #tabs '). Tabs (' Gettabindex ', currenttab);
if (TabIndex = = 1) {
Alert (' Kiss, there's someone up front, we can't afford to do this. ^@^!!');
return false;
}
$.each (Alltabtitle, function (i, n) {
if (I < TabIndex) {
if (n!= onlyopentitle) {
$ (' #tabs '). Tabs (' Close ', n);
}
}
});
Break
Case "Exit":
$ (' #closeMenu '). Menu (' hide ');
Break
}
}
The Tabcloseeven method in JS is changed to
Copy Code code as follows:
function Tabcloseeven () {
$ (' #mm '). Menu ({
Onclick:function (item) {
Closetab (item.id);
}
});
return false;
}
This is OK, the code is more elegant than the original!
Call refresh, when the current tab is closed, call Closetab (' action ')//action can be refresh (refresh), close (off)
When used in an IFRAME, be so excrement top.closetab (' action ');
Click here to download the latest Easyui application examples