jquery判断input是否为空的方法:首先创建isempty函数;然后在函数内通过id获取inp......
2021-01-14
版权所有:https://wWw.pxcodeS.com
在jquery中打开新窗口的方法:1、创建一个form表单,通过表单提交来实现新标签页打开;2、通过“window.open('_blank');”来打开;3、通过“setTimeout(window.open(...);”方式来打开。
推荐:《jquery视频教程》
jquery新窗口打开的几种方式
第一种:创建一个form表单,通过表单提交来实现新标签页打开。
var form = document.createElement(‘form‘);form.action = ‘www.baidu.com?id=1‘;form.target = ‘_blank‘;form.method = ‘pOST‘;document.body.appendChild(form);form.submit();第二种:
var tempwindow=window.open('_blank');tempwindow.location='www.baidu.com' ;第三种:
setTimeout(window.open('www.baidu.com'), 500);第四种:(与第一种相似)
/* 在新窗口中打开 */function openNewWindow(url) { var a = document.createElement('a'); a.setAttribute('href', url); a.setAttribute('target', '_blank'); var id = Math.random(10000, 99999); a.setAttribute('id', id); // 防止反复添加 if (!document.getElementById(id)) { document.body.appendChild(a); } a.click();}//方法调用openNewWindow('www.baidu.com');注:以上方法js中均可适用,若页面跳转的动作是在ajax方法执行后的,需要设置ajax同步执行。添加属性:async:false。如:
$.ajax({ type: 'post', data: param, url: 'ActionUrl', dataType: 'json', async:false, success: function (msg) {openNewWindow('www.baidu.com');}以上就是在jquery中如何打开新的窗口的详细内容,更多请关注少儿编程网其它相关文章!
来源:php中文网
版权所有:https://wWw.pxcodeS.com
相关文章:
标签:
相关文章