jquery中怎么打开新窗口
2023-05-20 17:06
jQuery
134
0
0
0
标题录入
封面图
jquery中打开新窗口的方法 第一种:创建一个form表单,通过表单提交来实现新标签页打开。 ``` var form = document.createElement(‘form‘); form.action = ‘https://www.outobe.com?id=1‘; form.target = ‘_blank‘; form.method = ‘POST‘; document.body.appendChild(form); form.submit(); ``` 第二种: ``` var tempwindow=window.open('_blank'); tempwindow.location='https://www.outobe.com' ; ``` 第三种: ``` setTimeout(window.open('https://www.outobe.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('https://www.outobe.com'); ``` 注:以上方法js中均可适用,若页面跳转的动作是在ajax方法执行后的,需要设置ajax同步执行。添加属性:async:false。如: ``` $.ajax({ type: 'post', data: param, url: 'ActionUrl', dataType: 'json', async:false, success: function (msg) { openNewWindow('https://www.outobe.com'); } ```
上一篇:
jquery获取当前页面的URL信息
下一篇:
jQuery通过input标签的name获取值
标题录入,一次不能超过6条
怎么运用逻辑思维进行推理?
T:0.007536s,M:245.52 KB
返回顶部
留言
留言
评论