- /* 以下のコードは XP ie8 では動くけど、win8 IE11(8モード)で動かない 開発の便宜を取って,setTimeout を挟む
- '<script>',
- 'function cb(o){window.parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',window.parent.JSON.stringify(o))}',
- '</script>',
- '<script src="', url, '"></script>' */
- ];
- X_Net_JSONP_onloadCount = 2;
- } else
- if( X_UA[ 'IE9' ] ){
- html = [
- '<script id="jp"></script>',
- '<script>',
- 'onunload=function(){clearTimeout(id)};',
- 'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw)}',
- 'function tm(){jp.src="', url ,'";nw=+new Date}',
- 'id=setTimeout(tm,16);',
- '</script>'
- ];
- X_Net_JSONP_onloadCount = 2;
- } else
- if( window[ 'JSON' ] ){
- html = [
- '<script>',
- 'nw=+new Date;',
- 'function cb(o){if(nw){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw);nw=0}}',
- //'function cb(o){if(nw){nw-=+new Date;parent.postMessage("', X_NET_JSONP_SEND_MSG_KEY,' "+nw+"|"+JSON.stringify(o),"', location.origin, '");nw=0}}',
- '</script>',
- '<script src="', url, '"></script>'
- ];
- X_Net_JSONP_onloadCount = 1;
- } else
- if( X_UA[ 'IE4' ] || X_UA[ 'MacIE' ] ){
- html = [
- '<script id="jn"></script>',
- '<script id="jp"></script>',
- '<script>',
- 'onunload=function(){clearTimeout(id)};',
- 'function cb(o){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw-16,', json2FileSize, ')}',
- 'function t1(){document.all.jn.src="', json2Path ,'";id=setTimeout("t2()",16);nw=+new Date}',
- 'id=setTimeout("t1()",16);',
- 'function t2(){if(window.JSON){document.all.jp.src="', url ,'"}else{id=setTimeout("t2()",16)}}',
- '</script>'
- ];
- X_Net_JSONP_onloadCount = 3;
- } else
- if( X_UA[ 'IE' ] < 8 ){ // ie5-7
- html = [
- '<script id="jn"></script>',
- '<script id="jp"></script>',
- '<script>',
- 'onunload=function(){clearTimeout(id)};',
- 'function cb(o){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw-16,', json2FileSize, ')}',
- 'function t1(){jn.src="', json2Path ,'";id=setTimeout(t2,16);nw=+new Date}',
- 'id=setTimeout(t1,16);',
- 'function t2(){if(window.JSON){jp.src="', url ,'"}else{id=setTimeout(t2,16)}}',
- '</script>'
- ];
- X_Net_JSONP_onloadCount = 3;
- } else {
- html = [
- '<script>',
- 'function cb(o){if(nw){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw,', json2FileSize, ');nw=0}}',
- 'nw=+new Date;',
- '</script>',
- '<script src="', json2Path, '"></script>',
- '<script src="', url, '"></script>'
- ];
- X_Net_JSONP_onloadCount = 1;
- };
-
- X_NET_JSONP_NinjaIframe
- [ 'refresh' ]( html.join( '' ) )
- [ 'listen' ]( [ X_EVENT_SUCCESS, X_EVENT_ERROR ], X_NET_JSONPWrapper, X_NET_JSONP_iframeListener );
+ if( X_UA[ 'Opera' ] ){
+ html = [
+ ( window[ 'JSON' ] ? '' : '<script src="' + json2Path + '"></script>' ),
+ '<script>',
+ 'onunload=function(){im.onload=im.onerror=""};',
+ 'nw=+new Date;',
+ 'function cb(o){if(nw){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw', window[ 'JSON' ] ? json2FileSize : 0 ,');nw=0}}',
+ '</script>',
+ '<script id="jp"></script>',
+ '<img id="im" src="', url, '" onload="jp.src=im.src" onerror="jp.src=im.src">'
+ ];
+ X_Net_JSONP_maxOnloadCount = 2;
+ } else
+ if( X_UA[ 'IE8' ] ){
+ html = [
+ // JavaScriptでunicode文字列をunescapeする
+ // http://perutago.seesaa.net/article/202801583.html
+
+ // http://blog.livedoor.jp/dankogai/archives/51503830.html
+ // Ajax - IE8にもJSON入ってます。使えるとは限らないけど
+ // Compatibility mode (別名Quirks mode) では、JSONオブジェクトは無効になります。iframeもだめです
+ '<script id="jp"></script>',
+ '<script>',
+ 'onunload=function(){clearTimeout(id)};',
+ 'nw=0;', // なぜか必要,,,
+ 'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',parent.JSON.stringify(o).replace(/\\\\u([a-fA-F0-9]{4})/g,function(a,b){return String.fromCharCode(parseInt(b,16))}),-nw)}',
+ //'function cb(o){if(nw){nw-=+new Date;postMessage("', X_NET_JSONP_SEND_MSG_KEY,' "+nw+"|"+parent.JSON.stringify(o).replace(/\\\\u([a-fA-F0-9]{4})/g,function(a,b){return String.fromCharCode(parseInt(b,16))}),"*");nw=0}}',
+ 'function tm(){jp.src="', url ,'";nw=+new Date}',
+ 'id=setTimeout(tm,16);',
+ '</script>'
+
+ /* 以下のコードは XP ie8 では動くけど、win8 IE11(8モード)で動かない 開発の便宜を取って,setTimeout を挟む
+ '<script>',
+ 'function cb(o){window.parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',window.parent.JSON.stringify(o))}',
+ '</script>',
+ '<script src="', url, '"></script>' */
+ ];
+ X_Net_JSONP_maxOnloadCount = 2;
+ } else
+ if( X_UA[ 'IE9' ] ){
+ html = [
+ '<script id="jp"></script>',
+ '<script>',
+ 'onunload=function(){clearTimeout(id)};',
+ 'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw)}',
+ 'function tm(){jp.src="', url ,'";nw=+new Date}',
+ 'id=setTimeout(tm,16);',
+ '</script>'
+ ];
+ X_Net_JSONP_maxOnloadCount = 2;
+ } else
+ if( window[ 'JSON' ] ){
+ html = [
+ '<script>',
+ 'nw=+new Date;',
+ 'function cb(o){if(nw){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw);nw=0}}',
+ //'function cb(o){if(nw){nw-=+new Date;parent.postMessage("', X_NET_JSONP_SEND_MSG_KEY,' "+nw+"|"+JSON.stringify(o),"', location.origin, '");nw=0}}',
+ '</script>',
+ '<script src="', url, '"></script>'
+ ];
+ X_Net_JSONP_maxOnloadCount = 1;
+ } else
+ if( X_UA[ 'IE4' ] || X_UA[ 'MacIE' ] ){
+ html = [
+ '<script id="jn"></script>',
+ '<script id="jp"></script>',
+ '<script>',
+ 'onunload=function(){clearTimeout(id)};',
+ 'function cb(o){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw-16,', json2FileSize, ')}',
+ 'function t1(){document.all.jn.src="', json2Path ,'";id=setTimeout("t2()",16);nw=+new Date}',
+ 'id=setTimeout("t1()",16);',
+ 'function t2(){if(window.JSON){document.all.jp.src="', url ,'"}else{id=setTimeout("t2()",16)}}',
+ '</script>'
+ ];
+ X_Net_JSONP_maxOnloadCount = 3;
+ } else
+ if( X_UA[ 'IE' ] < 8 ){ // ie5-7
+ html = [
+ '<script id="jn"></script>',
+ '<script id="jp"></script>',
+ '<script>',
+ 'onunload=function(){clearTimeout(id)};',
+ 'function cb(o){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw-16,', json2FileSize, ')}',
+ 'function t1(){jn.src="', json2Path ,'";id=setTimeout(t2,16);nw=+new Date}',
+ 'id=setTimeout(t1,16);',
+ 'function t2(){if(window.JSON){jp.src="', url ,'"}else{id=setTimeout(t2,16)}}',
+ '</script>'
+ ];
+ X_Net_JSONP_maxOnloadCount = 3;
+ } else {
+ html = [
+ '<script>',
+ 'function cb(o){if(nw){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw,', json2FileSize, ');nw=0}}',
+ 'nw=+new Date;',
+ '</script>',
+ '<script src="', json2Path, '"></script>',
+ '<script src="', url, '"></script>'
+ ];
+ X_Net_JSONP_maxOnloadCount = 2;
+ };
+
+ X_NET_JSONPWrapper
+ [ 'refresh' ]( html.join( '' ) )
+ [ 'listen' ]( [ 'ninjaload', 'ninjaerror' ], X_NET_JSONP_iframeListener );
+
+ X_NET_JSONPWrapper._busy = true;
+ },
+
+ cancel : function(){
+ X_NET_JSONPWrapper.reset();
+ X_NET_JSONPWrapper._canceled = true;
+ },
+
+ reset : function(){
+ X_NET_JSONPWrapper._busy = X_NET_JSONPWrapper._canceled = false;
+ X_Net_JSONP_onloadCount = 0;
+ X_NET_JSONPWrapper[ 'unlisten' ]( [ 'ninjaload', 'ninjaerror' ], X_NET_JSONP_iframeListener );
+ X_NET_JSONPWrapper[ 'refresh' ]( '' );
+ X_Net_JSONP_errorTimerID && X_Timer_remove( X_Net_JSONP_errorTimerID );
+ }
+ }
+ );