X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F05_util%2F01_XNinjaIframe.js;h=8507c5e3a644d50c757da75ef7b611231406a8b1;hb=094b0536bafe5efd70540698cf74ab13ece03ebb;hp=2eeaaa9ca372439bef8bde50c16de49a5443823e;hpb=50462b7b22a3c42bdbf2fb84d782937f817368f4;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/05_util/01_XNinjaIframe.js b/0.6.x/js/05_util/01_XNinjaIframe.js index 2eeaaa9..8507c5e 100644 --- a/0.6.x/js/05_util/01_XNinjaIframe.js +++ b/0.6.x/js/05_util/01_XNinjaIframe.js @@ -1,6 +1,9 @@ /* * http://msdn.microsoft.com/ja-jp/library/ie/hh180174%28v=vs.85%29.aspx * 孤立するとウィンドウ オブジェクトのプロパティが消去される + * + * http://qiita.com/sou/items/3380d4fa9b08b27bb387 + * モバイルブラウザでの iframe の挙動(Mobile Safari, Chrome for Android) */ // TODO Node.inherits @@ -69,14 +72,19 @@ X[ 'Util' ][ 'NinjaIframe' ] = Node[ 'inherits' ]( this._iwin.location.reload(); }; - if( !opt_contentHTML ) return this; + if( !opt_contentHTML && opt_contentHTML !== '' ) return this; this._contentHTML = opt_contentHTML; - X_UA[ 'IE' ] < 9 || X_Util_NinjaIframe_writeToIframe( this ); + + if( !( X_UA[ 'IE' ] < 9 ) ){ + X_Util_NinjaIframe_writeToIframe( this ); + this._ready = true; + }; return this; }, + // TODO close -> kill 'close' : function(){ X_ViewPort[ 'unlisten' ]( X_EVENT_AFTER_UPDATE, this, X_Util_NinjaIframe_handleEvent ); this.call( 'close' ); @@ -100,7 +108,7 @@ function X_Util_NinjaIframe_handleEvent( e ){ this[ 'listen' ]( [ X_UA[ 'IE' ] < 9 ? 'readystatechange' : 'load', 'error' ], this, X_Util_NinjaIframe_handleEvent ); if( !( X_UA[ 'IE' ] < 9 ) ){ - this._contentHTML && X_Util_NinjaIframe_writeToIframe( this ); + ( this._contentHTML || this._contentHTML === '' ) && X_Util_NinjaIframe_writeToIframe( this ); this._ready = true; return; }; @@ -110,18 +118,18 @@ function X_Util_NinjaIframe_handleEvent( e ){ if( ( raw.readyState !== 'complete' && raw.readyState !== 'loaded' ) ) break; // ie9- if( !this._ready ){ - this._contentHTML && X_Util_NinjaIframe_writeToIframe( this ); + ( this._contentHTML || this._contentHTML === '' ) && X_Util_NinjaIframe_writeToIframe( this ); this._ready = true; break; }; // onload case 'load' : console.log( 'iframe load.' ); - this[ 'asyncDispatch' ]( X_EVENT_SUCCESS ); + this[ 'asyncDispatch' ]( 'ninjaload' ); break; case 'error' : - this[ 'asyncDispatch' ]( X_EVENT_ERROR ); + this[ 'asyncDispatch' ]( 'ninjaerror' ); break; }; @@ -134,7 +142,6 @@ function X_Util_NinjaIframe_writeToIframe( that ){ html = that._contentHTML; delete that._contentHTML; - that._ready = true; idoc.open(); idoc.writeln( html );