chengwl 5 anni fa
parent
commit
142ebb84bf

+ 20 - 3
wp-content/plugins/coupon-creator/src/resources/js/coupon-test.js

@@ -1,9 +1,20 @@
+function newWin() {  
+	var a = document.createElement("a");  
+	a.setAttribute("target","_blank");  
+	a.setAttribute("id", "newWin");  
+	// 防止反复添加  
+	if(!document.getElementById("newWin")) {                       
+		document.body.appendChild(a);  
+	}  
+}  
 jQuery(function($){
+	newWin()
 	$('.vodal-close').click(function () {
 		$('.cover').hide()
 	})
 	$(document).on('click','.coupon_link', function (e) {
-        e.preventDefault();
+		e.preventDefault();
+		var flag = false;   
 		var $coupon_id = $( this ).data( 'coupon-id' );
 		var $ajax_action = $( this ).data('ajax-action');
 		var vodal=$(document).find('.vodal-dialog')
@@ -27,9 +38,13 @@ jQuery(function($){
 					$vodal.find('.instruction-subtitle').html(data.code)
 					$('.cover').css('display', 'flex')
 					window.setTimeout(function () {
+						$("#newWin").attr("href",data.link);//当回调的时候更改页面上或创建的某个a标签的href   
+						   flag = true;//更改标志   
+						   $("#newWin")[0].click();
 						console.log(data.link);
-						window.location.assign(data.link);
-					}, 6000);
+						// window.location.assign(data.link);
+						// tempwindow.location.href = data.link
+					}, 3000);
 				} else {
 
 
@@ -38,6 +53,8 @@ jQuery(function($){
 			}
 		} );
 
+		
+
 	} );
 
 } );