js jquery新窗口打开的几种方式
第一种:创建一个form表单,通过表单提交来实现新标签页打开。
var form = document.createElement(‘form‘);form.action = ‘?id=1‘;form.target = ‘_blank‘;form.method = ‘POST‘;document.body.appendChild(form);form.submit();
第二种:
var tempwindow=window.open('_blank');tempwindow.location='' ;
第三种:(与第一种相似)
/* 在新窗口中打开 */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('');