IE8 及 360 ajax window.open

回覆文章
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

IE8 及 360 ajax window.open

文章 yehlu »

代碼: 選擇全部

<!DOCTYPE html>
<html>
<head>
 <!--[if lt IE 9]>
 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
 <![endif]-->

 <!-- IE9 以下的 cross site ajax -->
 <!--[if lte IE 9]>
 <script type="text/javascript" src="jquery.xdomainrequest.min.js"></script>
 <![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<style>
#myButton {
    border: red outset 4px;
    display: inline-block;
    background-color: gray;
    border-radius: 5px;
    cursor: pointer;
}
</style>
</head>
<div id="myButton">Click Me</div>
<script>
$('#myButton').click(function() {
    $.ajax({
        url: 'echo_json.php',
        type: 'post',
        datatype: 'json',
        async: false,
        data: {"ids" : ""},
        success: function(data) {
            //console.log(data);
            if(true){
                window.open(data.URL,'_blank');
            }else{
                alert('Error');
            }
        }
    });
});
</script>

代碼: 選擇全部

<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5,
    'url' => 'http://www.551.com.tw',
    'URL' => 'http://www.551.com.tw',    
);

//$arr = array();
header('Content-Type: application/json');
//echo "{}";
echo json_encode($arr);

yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: IE8 及 360 ajax window.open

文章 yehlu »

代碼: 選擇全部

<!DOCTYPE html>
<html>
<head>
 <!--[if lt IE 9]>
 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
 <![endif]-->

 <!-- IE9 以下的 cross site ajax -->
 <!--[if lte IE 9]>
 <script type="text/javascript" src="jquery.xdomainrequest.min.js"></script>
 <![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<style>
#myButton {
    border: red outset 4px;
    display: inline-block;
    background-color: gray;
    border-radius: 5px;
    cursor: pointer;
}
</style>
</head>
<div id="myButton">Click Me</div>
<script>
$('#myButton').click(function() {
    var popup = window.open('about:blank', '_blank');
    $.ajax({
        url: 'echo_json.php',
        type: 'post',
        datatype: 'json',
        async: false,
        data: {"ids" : ""},
        success: function(data) {
            //console.log(data);
            if(true){
                //window.open(data.URL,'_blank');
                popup.location = data.URL;
            }else{
                alert('Error');
            }
        }
    });
});
</script>

回覆文章

回到「HTML + CSS」