How to open a new window in jquery
Nov 18, 2020 pm 01:39 PMHow to open a new window in jquery: 1. Create a form and submit the form to open a new tab; 2. Open it through "window.open('_blank');"; 3. , open through "setTimeout(window.open(...);" method.
The operating environment of this tutorial: windows7 system, jquery version 3.3.1, This method is suitable for all brands of computers.
Recommended: "jquery video tutorial"
Several ways to open a new jquery window
The first one : Create a form and open a new tab through form submission.
var form = document.createElement(‘form‘); form.action = ‘www.baidu.com?id=1‘; form.target = ‘_blank‘; form.method = ‘POST‘; document.body.appendChild(form); form.submit();
Second type:
var tempwindow=window.open('_blank'); tempwindow.location='www.baidu.com' ;
Third type: (Similar to the first type)
/* 在新窗口中打开 */ 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');
The above is the detailed content of How to open a new window in jquery. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of jQuery reference methods: Quick start guide

How to use PUT request method in jQuery?

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags

In-depth analysis: jQuery's advantages and disadvantages

Understand the role and application scenarios of eq in jQuery

How to tell if a jQuery element has a specific attribute?
