在jquery中打开新窗口的方法:1、创建一个form表单,通过表单提交来实现新标签页打开;2、通过“window.open('_blank');”来打开;3、通过“setTimeout(window.open(...);”方式来打开。
本教程操作环境:windows7系统、
jquery
3.3.1版,该方法适用于所有品牌电脑。
推荐:《
jquery视频教程
》
jquery新窗口打开的几种方式
第一种:创建一个form表单,通过表单提交来实现新标签页打开。
基于jQuery的AJAX和JSON的实例 中文WORD版
本文档主要讲述的是基于jQuery的AJAX和JSON的实例;过jQuery内置的AJAX功能,直接访问后台获得JSON格式的数据,然后通过jQuer把数据绑定到事先设计好的html模板上,直接在页面上显示。有需要的朋友可以下载看看
下载
第二种:
第三种:(与第一种相似)
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' ;/* 在新窗口中打开 */
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');