当前位置:网站首页>Several ways to trigger link jump

Several ways to trigger link jump

2022-06-21 09:15:00 Tie Hanhan plus

There are several ways to jump links

One 、window.location.href Way to jump

var openUrl = 'http://www.baidu.com';
window.location.href = openUrl;

Two 、window.open Way to jump

var openUrl = 'http://www.baidu.com';
window.open(openUrl, '_blank');
// window.open(openUrl, '_self');

3、 ... and 、a Label mode jump

The code is as follows ( Example ):

    // IOS and Android Trigger link mode 
	var openUrl = 'http://www.baidu.com';
    if (tempA) {
    
         document.body.removeChild(tempA);
     }
     var tempA= document.createElement('a');
     tempA.href = openUrl;
     tempA.style.display = 'none';
     console.log(' establish a label ', tempA);
     tempA.click();

Four 、iframe Label mode jump

The code is as follows ( Example ):

	// web Browser pass iframe Tag trigger link 
	openUrl ='http://www.baidu.com';
	if (ifr) {
    
	    document.body.removeChild(ifr);
	}
	var ifr = document.createElement('iframe');
	ifr.src= openUrl;
	ifr.style.display = 'none';
	document.body.appendChild(ifr);
原网站

版权声明
本文为[Tie Hanhan plus]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221446082027.html

随机推荐