js 自己项目中几种打开或弹出页面的方法
自己项目中,几种打开或弹出页面的方法(部分需要特定环境下)
var blnTop = false;//是否在顶层显示
///动态生成模态窗体(通过字符串生成)
///strModalId:模态窗体ID
///strTitle:模态窗体标题
///strContent:模态窗体html字符串内容
///strFooter:模态窗体右下方html字符串内容
///intWidth:模态窗体的宽度
///intHeight:模态窗体的高度
var ModeDialogContent = function (strModalId, strTitle, strContent, strFooter, intWidth, intHeight) {
if (strModalId == null || strModalId == '') {
abp.message.error("请指定对话框ID", "消息提示");
return;
}
var strStyle = "";
if (intWidth != null && intWidth != "")
strStyle = "width:" + intWidth + "px;";
if (intHeight != null && intHeight != "")
strStyle += "height:" + intHeight + "px";
if (strStyle != "")
strStyle = " style='" + strStyle + "'"; var strModalHtml = "<div class='modal fade' id='" + strModalId + "' tabindex='-1' aria-hidden='true' data-backdrop='static' role='dialog' aria-hidden='true'>";
strModalHtml += "<div class='modal-dialog' " + strStyle + ">";
strModalHtml += "<div class='modal-content' " + strStyle + ">";
strModalHtml += "<div class='modal-header'>";
strModalHtml += "<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>";
strModalHtml += "<h4 class='modal-title' >" + strTitle + "</h4></div>";
strModalHtml += "<div class='modal-body'>" + strContent + "</div>";
strModalHtml += "<div class='modal-footer'>";
strModalHtml += strFooter;
strModalHtml += "<button type='button' class='btn btn-danger' data-dismiss='modal'><i class='fa fa-times'></i> 关闭</button>";
strModalHtml += "</div>";
strModalHtml += "</div>";
strModalHtml += "</div>";
strModalHtml += "</div>"; var objHtml = $(strModalHtml);
objHtml.find(".modal-body").height($(strModalHtml).find(".modal-content").height() - 75);//设置URL地址的高度
//是否在顶层显示
if (blnTop) {
$(strModalHtml).appendTo(window.top.$("body"));
window.top.$("#" + strModalId).modal("show");
}
else {
$(strModalHtml).appendTo(this.$("body"));
$("#" + strModalId).modal("show");
}
} ///动态生成模态窗体顶层显示
///strModalId:模态窗体ID
///strTitle:模态窗体标题
///strContent:模态窗体html字符串内容
///strFooter:模态窗体右下方html字符串内容
///intWidth:模态窗体的宽度
///intHeight:模态窗体的高度
var TopModeDialogContent = function (strModalId, strTitle, strContent, strFooter, intWidth, intHeight) {
blnTop = true;//顶层显示
ModeDialogContent(strModalId, strTitle, strContent, strFooter, intWidth, intHeight);
blnTop = false;//修改成默认值
} ///动态生成模态窗体(通过对像生成)
///strModalId:模态窗体ID
///strTitle:模态窗体标题
///strContent:模态窗体对像内容
///strFooter:模态窗体右下角对像内容
///intWidth:模态窗体的宽度
///intHeight:模态窗体的高度
var ModeDialogObjContent = function (strModalId, strTitle, objContent, objFooter, intWidth, intHeight) {
if (strModalId == null || strModalId == '') {
abp.message.error("请指定对话框ID", "消息提示");
return;
}
var strStyle = "";
if (intWidth != null && intWidth != "")
strStyle = "width:" + intWidth + "px;";
if (intHeight != null && intHeight != "")
strStyle += "height:" + intHeight + "px";
if (strStyle != "")
strStyle = " style='" + strStyle + "'"; var strModalHtml = "<div class='modal fade' id='" + strModalId + "' tabindex='-1' aria-hidden='true' data-backdrop='static' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>";
strModalHtml += "<div class='modal-dialog' " + strStyle + ">";
strModalHtml += "<div class='modal-content' " + strStyle + ">";
strModalHtml += "<div class='modal-header'>";
strModalHtml += "<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>";
strModalHtml += "<h4 class='modal-title'>" + strTitle + "</h4></div>";
strModalHtml += "<div class='modal-body'></div>";
strModalHtml += "<div class='modal-footer'>";
strModalHtml += "<button type='button' class='btn btn-default' data-dismiss='modal'><i class='fa fa-times'></i> 关闭</button>";
strModalHtml += "</div>";
strModalHtml += "</div>";
strModalHtml += "</div>";
strModalHtml += "</div>"; var objHtml = $(strModalHtml);
objHtml.find(".modal-body").append(objContent);
objHtml.find(".modal-footer").append(objFooter);
objHtml.find(".modal-body").height($(strModalHtml).find(".modal-content").height() - 75);//设置URL地址的高度
//是否在顶层显示
if (blnTop) {
$(objHtml).appendTo(window.top.$("body"));
window.top.$("#" + strModalId).modal("show");
}
else {
$(objHtml).appendTo(this.$("body"));
$("#" + strModalId).modal("show");
}
} ///动态生成模态窗体顶层显示(通过对像生成)
///strModalId:模态窗体ID
///strTitle:模态窗体标题
///strContent:模态窗体对像内容
///strFooter:模态窗体右下角对像内容
///intWidth:模态窗体的宽度
///intHeight:模态窗体的高度
var TopModeDialogObjContent = function (strModalId, strTitle, objContent, objFooter, intWidth, intHeight) {
blnTop = true;
ModeDialogObjContent(strModalId, strTitle, objContent, objFooter, intWidth, intHeight);
blnTop = false;
} ///动态生成模态窗体(通过URL生成)
///strModalId:模态窗体ID
///strTitle:模态窗体标题
///strUrl:模态窗体URL
///intWidth:模态窗体的宽度
///intHeight:模态窗体的高度
var ModeDialogUrl = function (strModalId, strTitle, strUrl, intWidth, intHeight) {
if (strUrl == null || strUrl == '') {
abp.message.error("无连接地址", "消息提示");
return;
}
strUrl = GetPath(strUrl);//标准化地址
var strStyle = "";
if (intWidth != null && intWidth != "")
strStyle = "width:" + intWidth + "px;";
if (intHeight != null && intHeight != "")
strStyle += "height:" + intHeight + "px";
if (strStyle != "")
strStyle = " style='" + strStyle + "'"; var strModalHtml = "<div class='modal fade' id='" + strModalId + "' tabindex='-1' role='dialog' aria-hidden='true' aria-hidden='true' data-backdrop='static'>";
strModalHtml += "<div class='modal-dialog' " + strStyle + ">";
strModalHtml += "<div class='modal-content' " + strStyle + ">";
strModalHtml += "<div class='modal-header'>";
strModalHtml += "<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>";
strModalHtml += "<h4 class='modal-title' >" + strTitle + "</h4></div>";
strModalHtml += "<div class='modal-body' style='width:100%;'><iframe style='width:100%;height:100%' frameborder='0' scrolling='auto' src='" + strUrl + "'></iframe></div>";
strModalHtml += "</div>";
strModalHtml += "</div>";
strModalHtml += "</div>";
var objHtml = $(strModalHtml);
objHtml.find(".modal-body").height($(strModalHtml).find(".modal-content").height() - 75);//设置URL地址的高度
//是否在顶层显示
if (blnTop) {
objHtml.appendTo(window.top.$("html"));
window.top.$("#" + strModalId).modal("show");
}
else {
objHtml.appendTo(this.$("html"));
$("#" + strModalId).modal("show");
}
} ///动态生成模态窗体顶层显示(通过对像生成)
///strModalId:模态窗体ID
///strTitle:模态窗体标题
///strUrl:模态窗体URL
///intWidth:模态窗体的宽度
///intHeight:模态窗体的高度
var TopModeDialogUrl = function (strModalId, strTitle, strUrl, intWidth, intHeight) {
blnTop = true;
ModeDialogUrl(strModalId, strTitle, strUrl, intWidth, intHeight);
blnTop = false;
} ///模式窗口弹出(指定大小)
///strTitle:窗体标题
///strUrl:内容显示地址
///intWidth:窗体宽度
///intHeight:窗休息高度
var ModelDialog = function (strTitle, strUrl, intWidth, intHeight) {
if (strUrl == null || strUrl == '') {
abp.message.error("无连接地址", "消息提示");
return;
}
strUrl = GetPath(strUrl);//标准化地址
DiyModal.window({
title: strTitle,
url: strUrl,
width: intWidth,
height: intHeight,
fullscreen: false
////afterClose: function () {
//// table.reload();
////}
}).open();
}; ///模式窗口弹出(全屏展示)
///strTitle:窗体标题
///strUrl:内容显示地址
var FullModelDialog = function (strTitle, strUrl) {
ModelDialog(strTitle, strUrl, (window.innerWidth * 0.96), (window.innerHeight * 0.96));
}; var blnSon = false;//是否子窗口打开
///浏览器弹出窗口
///strTitle:窗体标题
///strUrl:内容显示地址
///intWidth:窗体宽度
///intHeight:窗休息高度
var WindowOpen = function (strTitle, strUrl, intWidth, intHeight) {
if (strUrl == null || strUrl == '') {
abp.message.error("无连接地址", "消息提示");
return;
}
strUrl = GetPath(strUrl);//标准化地址
if (strTitle == null || strTitle == '') {
strTitle = '';
}
if (intWidth == null || intWidth == '') {
intWidth = 0;
}
if (intHeight == null || intHeight == '') {
intHeight = 0;
}
if (intWidth == 0 || intHeight == 0) {
window.open(strUrl, strTitle, (blnSon ? 'fullscreen=0,' : '') + 'height=' + screen.height + ', width=' + screen.width + ', top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
}
else {
window.open(strUrl, strTitle, (blnSon ? 'fullscreen=0,' : '') + 'height=' + intHeight + ', width=' + intWidth + ', top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
}
}; ///浏览器弹出窗口
///strTitle:窗体标题
///strUrl:内容显示地址
///intWidth:窗体宽度
///intHeight:窗休息高度
var WindowSonOpen = function (strTitle, strUrl, intWidth, intHeight) {
blnSon = true;
WindowOpen(strTitle, strUrl, intWidth, intHeight);
blnSon = false;
}; ///当前浏览器原地址跳转
///strUrl:内容显示地址
var WindowLocation = function (strUrl) {
if (strUrl == null || strUrl == '') {
abp.message.error("无连接地址", "消息提示");
return;
}
strUrl = GetPath(strUrl);//标准化地址
window.location.href = strUrl;
}; ///当前浏览器顶级窗口地址跳转
///strUrl:内容显示地址
var WindowTopLocation = function (strUrl) {
if (strUrl == null || strUrl == '') {
abp.message.error("无连接地址", "消息提示");
return;
}
strUrl = GetPath(strUrl);//标准化地址
window.top.location.href = strUrl;
}; ///当前浏览器父级窗口地址跳转
///strUrl:内容显示地址
var WindowParentLocation = function (strUrl) {
if (strUrl == null || strUrl == '') {
abp.message.error("无连接地址", "消息提示");
return;
}
strUrl = GetPath(strUrl);//标准化地址
window.parent.location.href = strUrl;
}; ///当前浏览器指定框架地址重定向
///strUrl:内容显示地址
///strFrame:是重定向的框架名称
var WindowFramesLocation = function (strFrame, strUrl) {
if (strUrl == null || strUrl == '') {
abp.message.error("无连接地址", "消息提示");
return;
}
strUrl = GetPath(strUrl);//标准化地址
if (strFrame == null || strFrame == '') {
abp.message.error("框架名称为空", "消息提示");
return;
}
if (window.parent.iframeName != null) {//查找父级IFRAME
window.parent.iframeName.location.href = strUrl;
} else if (window.parent.frames[strFrame] != null) { //查找父级下面的IFRAME
window.parent.frames[strFrame].location.href = strUrl;
} else if (window.frames[strFrame] != null) {//查找下级的IFAME
window.frames[strFrame].location.href = strUrl;
} else {
abp.message.error("找不到您所指定的框架名", "消息提示");
}
}; ///添加选项卡
///strUrl:选项卡URL地址
///strName:选项卡名称
var AddTab = function (strName, strUrl) {
if (strUrl == undefined || $.trim(strUrl).length == 0 || strName == undefined || $.trim(strName).length == 0) {
abp.message.error("地址及选项卡名称不能为空", "消息提示");
return false;
}
strUrl = GetPath(strUrl);//标准化地址
var strIframe = "iframe" + Math.floor(Math.random() * 101);//自动生成iframe框架名称及ID
var flag = true;//是否存在此选项卡
//查询选项卡中是否已存在了要添加的选项卡,如果存在了,就选中处理
window.parent.$('.menuTab').each(function () {
if ($(this).data('id') == strUrl) {
if (!$(this).hasClass('active')) {
$(this).addClass('active').siblings('.menuTab').removeClass('active');
$.learuntab.scrollToTab(this);
window.parent.$('.mainContent .LRADMS_iframe').each(function () {
if ($(this).data('id') == strUrl) {
$(this).show().siblings('.LRADMS_iframe').hide();
return false;
}
});
}
flag = false;
return false;
}
});
//添加选项卡
if (flag) {
var str = '<a href="javascript:;" class="active menuTab" data-id="' + strUrl + '">' + strName + ' <i class="fa fa-remove"></i></a>';
window.parent.$('.menuTab').removeClass('active');
var str1 = '<iframe class="LRADMS_iframe" id="' + strIframe + '" name="' + strIframe + '" width="100%" height="100%" src="' + strUrl + '" frameborder="0" data-id="' + strUrl + '" seamless></iframe>';
window.parent.$('.mainContent').find('iframe.LRADMS_iframe').hide();
window.parent.$('.mainContent').append(str1);
window.parent.$('.menuTabs .page-tabs-content').append(str);
$.learuntab.scrollToTab($('.menuTab.active'));
}
}; ///AJAX请求
///strUrl:请求URL
///btnObj:请求按钮对像
var AjaxFun = function (strUrl, btnObj) {
var paramData = "{'" + GetParamJson(strUrl) + "'}";
var btnName = btnObj.innerText;
var strUrl = GetPath(strUrl); $.ajax({
url: strUrl,
type: 'POST',
dataType: 'JSON',
data: paramData,
success: function (result) {
if (result != null) {
abp.message.success("", btnName + "成功!");
}
},
complete: function (XMLHttpRequest, status) { //请求完成后最终执行参数
if (status != 'success') {
abp.message.error("状态为:" + status, btnName + "请求有误!");
}
}
});
};
js 自己项目中几种打开或弹出页面的方法的更多相关文章
- [转]js中几种实用的跨域方法原理详解
转自:js中几种实用的跨域方法原理详解 - 无双 - 博客园 // // 这里说的js跨域是指通过js在不同的域之间进行数据传输或通信,比如用ajax向一个不同的域请求数据,或者通过js获取页面中不同 ...
- js中几种实用的跨域方法原理详解(转)
今天研究js跨域问题的时候发现一篇好博,非常详细地讲解了js几种跨域方法的原理,特分享一下. 原博地址:http://www.cnblogs.com/2050/p/3191744.html 下面正文开 ...
- js中几种实用的跨域方法原理详解
这里说的js跨域是指通过js在不同的域之间进行数据传输或通信,比如用ajax向一个不同的域请求数据,或者通过js获取页面中不同域的框架中(iframe)的数据.只要协议.域名.端口有任何一个不同,都被 ...
- js中几种实用的跨域方法原理详解【转】
源地址:http://www.cnblogs.com/2050/p/3191744.html 这里说的js跨域是指通过js在不同的域之间进行数据传输或通信,比如用ajax向一个不同的域请求数据,或者通 ...
- Java 项目中一种简单的动态修改配置即时生效的方式 WatchService
这种方式仅适合于比较小的项目,例如只有一两台服务器,而且配置文件是可以直接修改的.例如 Spring mvc 以 war 包的形式部署,可以直接修改resources 中的配置文件.如果是 Sprin ...
- 【转】js中几种实用的跨域方法原理详解
这里说的js跨域是指通过js在不同的域之间进行数据传输或通信,比如用ajax向一个不同的域请求数据,或者通过js获取页面中不同域的框架中(iframe)的数据.只要协议.域名.端口有任何一个不同,都被 ...
- java 项目中几种O实体类的概念
经常会接触到vo,do,dto的概念,本文从领域建模中的实体划分和项目中的实际应用情况两个角度,对这几个概念进行简析. 得出的主要结论是:在项目应用中,vo对应于页面上需要显示的数据(表单),do对应 ...
- Android Studio项目中三种依赖的添加方式
通常一个AS项目中的依赖关系有三种,一是本地依赖(主要是对本地的jar包),二是模块依赖,三是远程依赖:添加这些依赖的目的在于上我们想要在项目的某一个模块中使用其中的功能,比如okttp这个网络框架库 ...
- js和php中几种生成验证码的方式
之前做过取随机数和生成验证码的练习,都是通过取随机数作为数组下标,然后从数组中取值的方式(js): /*验证码*/ function sj_yzm(){ //存一个包括数字和字母的数组 var zon ...
随机推荐
- PHP批量导出数据为excel表格
之前用插件phoexcel写过批量导入数据,现在用到了批量导出,就记录一下,这次批量导出没用插件,是写出一个表格,直接输出 //$teacherList 是从数据库查出来的二维数组 $execlnam ...
- [原创]数据驱动决策:BI在零售业的数据化管理
无论是商业智能时代的应用建设,还是当下大数据时代的数据应用/数据产品建设,行业化.角色化与场景化,均是一个重要的趋势. 当下,许多企业逐步开始具备场景化思维,更为注重用户体验,业务运营更多的围绕用户的 ...
- 企业BI系统应用的切入点及五大策略
从技术的角度来看,BI的技术正在走向成熟,处于一个发展的阶段,但它促使了BI的应用在成本方面开始逐步的降低,越来越多的企业在BI应用方面取得了成功.从实施的角度来出发,实施商业智能系统是一项复杂的系统 ...
- MySql 简单统计查询消耗时间脚本
MySql 简单统计查询消耗时间脚本 by:授客 QQ:1033553122 drop procedure if exists selectTime; delimiter; create proced ...
- PRD文档怎么写
昨天学习PMP的相关文档,正好看到里面讲的PRD文档是怎么写的 就把一些学习过程,思维方式,还有用到的工具给记录下来 方便自己以后需要的时候,再去查阅,再读这个教程的时候,我顺便用脑图画了一下 脑图工 ...
- for之于while的优势
前言 for与while各有功效,下面就只列举for之于while的优势有哪些 优势 1.循环中提供了特殊的机会来将变量的作用域最小化.(无论是传统的还是for-each形式的)for循环,都允许声明 ...
- 如何在EF Core 使用存储过程
使用EF Core框架能快速的帮助我们进行常规的数据处理和项目开发,但是ORM虽然好用,但是在许多复杂逻辑的数据处理时,我个人还是偏向用SQL和存储过程的方式去处理,但是研究了一下目前最新版本的EF ...
- surging API
基于.NET CORE微服务框架 -谈谈surging API网关 基于.NET CORE微服务框架 -浅析如何使用surging surging 系列 NET Core 2.0 在WIN7系统 的H ...
- Windows下文件检索的基本姿势
要点 使用FindFirstFile和FindNextFile两个WindowsAPI,并配合链表或队列存储文件夹序列. C++源码(链表存储) #include <iostream> # ...
- windows下,怎么轻易拷贝一个文件的完整路径?
1. 到目录下,复制文件 2. win+R ,打开"运行"输入框 3.ctrl+v