X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F05_util%2F01_XNinjaIframe.js;h=e16f550d9ad47ac5f13b048df3c4fa85ba9a9872;hb=1bfbfbb850a390a1c46546d445961966e4cdf063;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..e16f550 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; }; @@ -132,9 +140,9 @@ function X_Util_NinjaIframe_writeToIframe( that ){ var raw = that[ '_rawObject' ], idoc = raw.contentDocument || that._iwin.document, html = that._contentHTML; - + + that._ready = true; // これを削除すると ie6,7,8 で Stack overflow at line : 0 意味不明 delete that._contentHTML; - that._ready = true; idoc.open(); idoc.writeln( html );