在新标签页中get方式打开url

window.open(loginurl_withaccout, "_blank");

下图中根据后台返回的url以及用户名密码字段,以及用户名密码动态生成了带账号的url。

$.ax('./front/getURLBySidAndUid', {sysid:sysid}, 'POST', function(d) {
var loginurl_withaccout = d.loginurl + "?"+d.namefield+"="+d.username+"&"+d.pwdfield+"="+d.userpwd;
console.info(loginurl_withaccout);
window.open(loginurl_withaccout, "_blank");
}, function(e) {
layer.alert('出问题啦~请稍后再试~',{title:'提示',icon: 2});
}, false); //同步

在新标签页中post方式打开url

下面这种方式支持IE9以上以及谷歌火狐.但是不支持360

/*获取系统带参数的登录url*/
$.ax('./front/getURLBySidAndUid', {sysid:sysid}, 'POST', function(d) { /*get跳转*/
/*var loginurl_withaccout = d.loginurl + "?"+d.namefield+"="+d.username+"&"+d.pwdfield+"="+d.userpwd;
window.open(loginurl_withaccout, "_blank");*/ /*post跳转*/
var params = new Array();
params.push({ name:d.namefield,value:d.username},{name:d.pwdfield,value:d.userpwd});
openPostWindow(d.loginurl,params,"_blank");
}, function(e) {
layer.alert('出问题啦~请稍后再试~',{title:'提示',icon: 2});
}, false); //同步 /**
* 动态创建form表单 - 实现post带参数跳转到新tab页
**/
function openPostWindow(url,params,name){
var tempForm = document.createElement("form");
tempForm.id="tempForm_post";
tempForm.method="post";
tempForm.enctype="application/x-www-form-urlencoded";
tempForm.action=url;
tempForm.target=name; /*打开新窗口*/
tempForm.style.display = "none";
//添加参数
for (var item in params) {
var input = document.createElement("input");
input.name = params[item].name;
input.value = params[item].value;
tempForm.appendChild(input);
}
document.body.appendChild(tempForm);
tempForm.submit();
document.body.removeChild(tempForm);
}

window.location和window.open区别

性质不同

  • window.location:window.location是window对象的属性。
  • window.open:window.open是window对象的方法。

用途不同

  • window.location:window.location用来替换当前页,也就是重新定位当前页 。
  • window.open:window.open用来让链接页面在窗口中打开。

打开网站不同

  • window.location:window.location只能在一个网站中打开本网站的网页。
  • window.open:window.open可以在一个网站上打开另外的一个网站的地址 。

JS打开url的几种方法的更多相关文章

  1. Openerp 中打开 URL 的三种 方法

    来自:http://shine-it.net/index.php/topic,8013.0.html 最近总结了,Openerp 中打开 URL 的三种 方法: 一.在form view 添加 < ...

  2. ajax请求参数中含有特殊字符"#"的问题 (另附上js编码解码的几种方法)

    使用ajax向后台提交的时候 由于参数中含有#  默认会被截断 只保留#之前的字符  json格式的字符串则不会被请求到后台的action 可以使用encodeURIComponent在前台进行编码, ...

  3. 使用urllib2打开网页的三种方法(Python2)

    python2才有urllib2模块,python3把urllib和urllib2封装成了urllib模块 使用urllib2打开网页的三种方法 #coding:utf-8 import urllib ...

  4. (转)C#调用默认浏览器打开网页的几种方法

    转载,原文地址:http://blog.csdn.net/testcs_dn/article/details/42246969 CSharp调用默认浏览器打开网页的几种方法 示例界面: 方法一:从注册 ...

  5. 提交(post)xml文件给指定url的2种方法

    原文:提交(post)xml文件给指定url的2种方法 1  这段代码是在网上搜到的,拿来共享,项目正好要用到.其中的data你只需要传递一个xml字符串就可以 protected   string  ...

  6. html table表格导出excel的方法 html5 table导出Excel HTML用JS导出Excel的五种方法 html中table导出Excel 前端开发 将table内容导出到excel HTML table导出到Excel中的解决办法 js实现table导出Excel,保留table样式

    先上代码   <script type="text/javascript" language="javascript">   var idTmr; ...

  7. js删除数据的几种方法

    js 删除数组几种方法 var arr=['a','b','c']; 若要删除其中的'b',有两种方法: 1.delete方法:delete arr[1] 这种方式数组长度不变,此时arr[1]变为u ...

  8. JS刷新页面的几种方法(转)

    Javascript刷新页面的几种方法: 1 history.go(0) 2 location.reload() 3 location=location 4 location.assign(locat ...

  9. JS刷新当前页面的几种方法总结

    reload 方法,该方法强迫浏览器刷新当前页面. 语法:location.reload([bForceGet]) 参数: bForceGet, 可选参数, 默认为 false,从客户端缓存里取当前页 ...

随机推荐

  1. 程序员编程时常用的mac快捷方式

    fn + F2/F3 = 调节音量 commend + shift +k = 显示或隐藏键盘 commend+shift +h = iPhone返回主页面 commend+ shift + hh = ...

  2. sftp-server 搭建编译

    下载开源代码 https://github.com/zwx230741/openssh-portable 编译 # autoconf # ./configure --prefix=xxx # make ...

  3. MySQL基础之表的管理

    添加和删除字段操作 添加字段 alter table tbl_name add 字段名称 字段属性 [完整性约束条件] [first|after 字段名称之后]; 删除字段 alter table t ...

  4. [Flink]测试用的fake温度传感器

    figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...

  5. unbuntu更换软件源

    编辑/etc/apt/sources.list文件,将文件中原有的国外源全部注释掉,文件头添加以下内容 ##中科大源 deb https://mirrors.ustc.edu.cn/ubuntu/ b ...

  6. 『009』Python

    『004』索引-Language Python 准备更新中

  7. luoguP3258 [JLOI2014]松鼠的新家

    树上差分 树上差分分析 使点x到点y的路径上(链上),全加上一个值,可以选择使用树上差分(不用线段树乱搞.... 首先,和普通的差分一样,要有一个tag.然而,对于一个结点,我们需要求出它全部儿子的t ...

  8. github配置ssh及多ssh key问题处理

    一.生成ssh公私钥 用ssh-keygen生成公私钥. $ssh-keygen -t rsa -C "你的邮箱" -f ~/.ssh/id_rsa_mult 在~/./ssh目录 ...

  9. c# 第21节 方法声明和调用

    本节内容: 1:为什么要有方法 2:方法的声明及使用 3:方法params 传入接收数组 4:值传递和引用传递 5:输出参数out 1:为什么要有方法 2:方法的声明及使用 声明实例: 3:方法par ...

  10. 毕业设计代做,各种系统微服务项目ssm项目,员工管理系统,微信小程序,购物商城,二手商城系统,销售系统,等等

    毕业设计代做,各种系统,微服务项目,ssm项目 小程序,商城等,期末作业等都可以,价格好说,长期接单, 有项目说明书,软件介绍相关文档,答辩的时候包过,知识点对接好,给你讲解等, 毕业设计代做,各种系 ...