当前位置: 编程技术>jquery
Jquery easyui模拟浏览器前进后退查看历史网页
来源: 互联网 发布时间:2014-10-08
本文导语: 例子,Jquery easyui如何模拟浏览器前进后退查看历史网页。 代码示例: /** * 打开窗口的简化 */ function easyuiWinNew(settings, level, tools) { if (!level) { level = 1; } var defaultSetting = { title : "new Title", modal : true, resizable : false, minimizab...
例子,Jquery easyui如何模拟浏览器前进后退查看历史网页。
代码示例:
/**
* 打开窗口的简化
*/
function easyuiWinNew(settings, level, tools) {
if (!level) {
level = 1;
}
var defaultSetting = {
title : "new Title",
modal : true,
resizable : false,
minimizable : false,
maximizable : false,
collapsible : false,
shadow : false,
closed : true,
width : 675,
height : 560,
onClose : function() {
var options = $("#easyuiwin" + level).window("options");
$("#easyuiwin" + level).window("destroy", true);
if (!$("#easyuiwin" + level).get(0)) {
$("").appendTo("body")
.window(options);
} else {
$("#easyuiwin" + level).window(options);
}
// 将相应的保存的信息删除
}
};
if (tools) {
$.extend(defaultSetting, {
tools : [{
iconCls : "icon-goback",
handler : function() {
easyuiWinBack(level);
}
}, {
iconCls : "icon-goforward",
handler : function() {
easyuiWinPre(level);
}
}, {
iconCls : "icon-history",
handler : function(event) {
var his_menu = $("");
var his_setting = $("#easyuiwin" + level)
.data("easyuiWinPageSetting");
for (var i = 0; i < his_setting.length; i++) {
his_menu
.append("
}
// 展示历史记录
his_menu.menu({}).menu("show", {
left : event.pageX,
top : event.pageY
});
}
}]
});
}
$.extend(defaultSetting, settings);
$("#easyuiwin" + level).remove();
$("body").append("");
$("#easyuiwin" + level).window(defaultSetting).window("open");
// 存储第一次打开窗口的信息
$("#easyuiwin" + level).data("easyuiWinPageSetting",
new Array($.extend(settings, {
page : 1
})));
// 设置当前页
$("#easyuiwin" + level).data("easyuiWinCurrentPage", 1);
}
function easyui_win_his_menu_click(title, href, level) {
easyuiWinChange({
title : title,
href : href
}, level);
}
/**
* 跳转到某个页面,其中setting是
*/
function easyuiWinGo(setting, level) {
if (!level) {
level = 1;
}
easyuiWinChange(setting, level);
// 存储页面跳转信息
// 设置当前页
var currentPage = $("#easyuiwin" + level).data("easyuiWinCurrentPage") + 1;
$("#easyuiwin" + level).data("easyuiWinCurrentPage", currentPage);
// 保存配置
var beforeArray = $("#easyuiwin" + level).data("easyuiWinPageSetting");
beforeArray.push($.extend(setting, {
page : currentPage
}));
$("#easyuiwin" + level).data("easyuiWinPageSetting", beforeArray);
}
// 窗口关闭
function easyuiWinClose(level) {
if (!level) {
level = 1;
}
$("#easyuiwin" + level).window("close");
}
// 后退
function easyuiWinBack(level) {
var currentPgae = $("#easyuiwin" + level).data("easyuiWinCurrentPage");
var beforeArray = $("#easyuiwin" + level).data("easyuiWinPageSetting");
// alert("currentPgae:"+currentPgae+"
// beforeArray-length:"+beforeArray.length);
if ((currentPgae - 1) >= 1) {
for (var i = 0; i < beforeArray.length; i++) {
var beforePage = beforeArray[i];
if (beforePage.page == (currentPgae - 1)) {
// 设置当前页
$("#easyuiwin" + level).data("easyuiWinCurrentPage",
(currentPgae - 1));
// 页面跳转
easyuiWinChange(beforePage, level);
}
}
}
}
// 前进
function easyuiWinPre(level) {
var currentPgae = $("#easyuiwin" + level).data("easyuiWinCurrentPage");
var beforeArray = $("#easyuiwin" + level).data("easyuiWinPageSetting");
// alert("currentPgae:"+currentPgae+"
// beforeArray-length:"+beforeArray.length);
if ((currentPgae + 1)
* 打开窗口的简化
*/
function easyuiWinNew(settings, level, tools) {
if (!level) {
level = 1;
}
var defaultSetting = {
title : "new Title",
modal : true,
resizable : false,
minimizable : false,
maximizable : false,
collapsible : false,
shadow : false,
closed : true,
width : 675,
height : 560,
onClose : function() {
var options = $("#easyuiwin" + level).window("options");
$("#easyuiwin" + level).window("destroy", true);
if (!$("#easyuiwin" + level).get(0)) {
$("").appendTo("body")
.window(options);
} else {
$("#easyuiwin" + level).window(options);
}
// 将相应的保存的信息删除
}
};
if (tools) {
$.extend(defaultSetting, {
tools : [{
iconCls : "icon-goback",
handler : function() {
easyuiWinBack(level);
}
}, {
iconCls : "icon-goforward",
handler : function() {
easyuiWinPre(level);
}
}, {
iconCls : "icon-history",
handler : function(event) {
var his_menu = $("");
var his_setting = $("#easyuiwin" + level)
.data("easyuiWinPageSetting");
for (var i = 0; i < his_setting.length; i++) {
his_menu
.append("
"
+ his_setting[i].title
+ "
");+ his_setting[i].title
+ "
}
// 展示历史记录
his_menu.menu({}).menu("show", {
left : event.pageX,
top : event.pageY
});
}
}]
});
}
$.extend(defaultSetting, settings);
$("#easyuiwin" + level).remove();
$("body").append("");
$("#easyuiwin" + level).window(defaultSetting).window("open");
// 存储第一次打开窗口的信息
$("#easyuiwin" + level).data("easyuiWinPageSetting",
new Array($.extend(settings, {
page : 1
})));
// 设置当前页
$("#easyuiwin" + level).data("easyuiWinCurrentPage", 1);
}
function easyui_win_his_menu_click(title, href, level) {
easyuiWinChange({
title : title,
href : href
}, level);
}
/**
* 跳转到某个页面,其中setting是
*/
function easyuiWinGo(setting, level) {
if (!level) {
level = 1;
}
easyuiWinChange(setting, level);
// 存储页面跳转信息
// 设置当前页
var currentPage = $("#easyuiwin" + level).data("easyuiWinCurrentPage") + 1;
$("#easyuiwin" + level).data("easyuiWinCurrentPage", currentPage);
// 保存配置
var beforeArray = $("#easyuiwin" + level).data("easyuiWinPageSetting");
beforeArray.push($.extend(setting, {
page : currentPage
}));
$("#easyuiwin" + level).data("easyuiWinPageSetting", beforeArray);
}
// 窗口关闭
function easyuiWinClose(level) {
if (!level) {
level = 1;
}
$("#easyuiwin" + level).window("close");
}
// 后退
function easyuiWinBack(level) {
var currentPgae = $("#easyuiwin" + level).data("easyuiWinCurrentPage");
var beforeArray = $("#easyuiwin" + level).data("easyuiWinPageSetting");
// alert("currentPgae:"+currentPgae+"
// beforeArray-length:"+beforeArray.length);
if ((currentPgae - 1) >= 1) {
for (var i = 0; i < beforeArray.length; i++) {
var beforePage = beforeArray[i];
if (beforePage.page == (currentPgae - 1)) {
// 设置当前页
$("#easyuiwin" + level).data("easyuiWinCurrentPage",
(currentPgae - 1));
// 页面跳转
easyuiWinChange(beforePage, level);
}
}
}
}
// 前进
function easyuiWinPre(level) {
var currentPgae = $("#easyuiwin" + level).data("easyuiWinCurrentPage");
var beforeArray = $("#easyuiwin" + level).data("easyuiWinPageSetting");
// alert("currentPgae:"+currentPgae+"
// beforeArray-length:"+beforeArray.length);
if ((currentPgae + 1)