PhoneGap InAppBrowser
90001 단어 PhoneGap
InAppBrowser
웹 브 라 우 저 보 기 를 표시 할 때 호출 window.open()
하거나 연결 을 열 면
합 니 다.var ref = window.open('http://apache.org', '_blank', 'location=yes');
주: InAppBrowser 창 은 표준 웹 브 라 우 저 와 유사 하 며, 콜 도 바 의 Api 에 접근 할 수 없습니다.
설명 하 다.
호출 된 물건
window.open
.방법.
접근 기능
3.0 판 에서 콜 도 바 는 외 장 프로그램 으로 장치 급 Api 를 실현 했다.CLI
plugin
명령 을 사용 하여 명령 열 인터페이스 에 설명 합 니 다. 프로젝트 를 추가 하거나 삭제 할 수 있 습 니 다. 이 기능 은: $ cordova plugin add org.apache.cordova.inappbrowser
$ cordova plugin ls
[ 'org.apache.cordova.inappbrowser' ]
$ cordova plugin rm org.apache.cordova.inappbrowser
이 명령 들 은 모든 맞 춤 형 플랫폼 에 적용 되 지만 다음 과 같은 특정한 플랫폼 설정 을 수정 합 니 다.
app/res/xml/config.xml
name="InAppBrowser">
name="android-package" value="org.apache.cordova.InAppBrowser" />
config.xml
name="InAppBrowser">
name="ios-package" value="CDVInAppBrowser" />
config.xml
name="InAppBrowser" />
addEventListener
이벤트 에 차단 기 를 추가 합 니 다
InAppBrowser
.ref.addEventListener(eventname, callback);
InAppBrowser
창 (InAppBrowser) InAppBrowser
에서 URL 을 불 러 오기 시작 합 니 다. InAppBrowser
가 URL 을 불 러 옵 니 다. InAppBrowser
가 URL 을 불 러 오 는 중 오류 가 발생 했 습 니 다. InAppBrowser
가 발생 하면 창 을 닫 습 니 다. InAppBrowserEvent
아 이 템 을 매개 변수 로 합 니 다. var ref = window.open('http://apache.org', '_blank', 'location=yes');
ref.addEventListener('loadstart', function() { alert(event.url); });
완전한 예시
</span><span class="pln">InAppBrowser</span><span class="pln">.</span><span class="pln">addEventListener</span><span class="pln"> Example</span><span class="tag"/><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"cordova.js"</span><span class="tag">></script></span><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="tag">></span><span class="pln">
</span><span class="com">// Wait for device API libraries to load</span><span class="pln">
</span><span class="com">//</span><span class="pln">
document</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">"</span><span class="str">deviceready</span><span class="str">"</span><span class="pun">,</span><span class="pln"> onDeviceReady</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
</span><span class="com">// device APIs are available</span><span class="pln">
</span><span class="com">//</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> onDeviceReady</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> ref </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
ref</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'loadstart'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> alert</span><span class="pun">(</span><span class="str">'start: '</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> event</span><span class="pun">.</span><span class="pln">url</span><span class="pun">);</span><span class="pln"> </span><span class="pun">});</span><span class="pln">
ref</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'loadstop'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> alert</span><span class="pun">(</span><span class="str">'stop: '</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> event</span><span class="pun">.</span><span class="pln">url</span><span class="pun">);</span><span class="pln"> </span><span class="pun">});</span><span class="pln">
ref</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'loaderror'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> alert</span><span class="pun">(</span><span class="str">'error: '</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> event</span><span class="pun">.</span><span class="pln">message</span><span class="pun">);</span><span class="pln"> </span><span class="pun">});</span><span class="pln">
ref</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'exit'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> alert</span><span class="pun">(</span><span class="pln">event</span><span class="pun">.</span><span class="pln">type</span><span class="pun">);</span><span class="pln"> </span><span class="pun">});</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="tag"></script></span><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span></span></code></pre>
<h1>removeEventListener</h1>
<blockquote>
<p> <code>InAppBrowser</code>.</p>
</blockquote>
<pre><code><span class="kwd">ref</span><span class="pun">.</span><span class="pln">removeEventListener</span><span class="pun">(</span><span class="pln">eventname</span><span class="pun">,</span><span class="pln"> callback</span><span class="pun">);</span><span class="pln">
</span></code></pre>
<ul>
<li> <p><strong>ref</strong>: <code>InAppBrowser</code> 。<em>() InAppBrowser</em></p> </li>
<li> <p><strong> </strong>: 。<em>( )</em></p>
<ul>
<li><strong>loadstart</strong>: <code>InAppBrowser</code> URL。</li>
<li><strong>loadstop</strong>: <code>InAppBrowser</code> URL。</li>
<li><strong>loaderror</strong>: <code>InAppBrowser</code> URL。</li>
<li><strong> </strong>: <code>InAppBrowser</code> 。</li>
</ul></li>
<li> <p><strong> </strong>: 。 <code>InAppBrowserEvent</code> 。</p> </li>
</ul>
<h2> </h2>
<ul>
<li>Android </li>
<li> </li>
<li>iOS</li>
<li>Windows Phone 7 8</li>
</ul>
<h2> </h2>
<pre><code><span class="kwd">var</span><span class="pln"> </span><span class="kwd">ref</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> myCallback </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> alert</span><span class="pun">(</span><span class="kwd">event</span><span class="pun">.</span><span class="pln">url</span><span class="pun">);</span><span class="pln"> </span><span class="pun">}</span><span class="pln">
</span><span class="kwd">ref</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'loadstart'</span><span class="pun">,</span><span class="pln"> myCallback</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">ref</span><span class="pun">.</span><span class="pln">removeEventListener</span><span class="pun">(</span><span class="str">'loadstart'</span><span class="pun">,</span><span class="pln"> myCallback</span><span class="pun">);</span><span class="pln">
</span></code></pre>
<h2> </h2>
<pre><code><span class="dec"><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"><title/></span><span class="pln">InAppBrowser</span><span class="pln">.</span><span class="pln">removeEventListener</span><span class="pln"> Example</span><span class="tag"/><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"cordova.js"</span><span class="tag">></script></span><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="tag">></span><span class="pln">
</span><span class="com">// Wait for device API libraries to load</span><span class="pln">
</span><span class="com">//</span><span class="pln">
document</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">"</span><span class="str">deviceready</span><span class="str">"</span><span class="pun">,</span><span class="pln"> onDeviceReady</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
</span><span class="com">// Global </span><span class="com">InAppBrowser</span><span class="com"> reference</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> iabRef </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> iabLoadStart</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
alert</span><span class="pun">(</span><span class="pln">event</span><span class="pun">.</span><span class="pln">type </span><span class="pun">+</span><span class="pln"> </span><span class="str">' - '</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> event</span><span class="pun">.</span><span class="pln">url</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> iabLoadStop</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
alert</span><span class="pun">(</span><span class="pln">event</span><span class="pun">.</span><span class="pln">type </span><span class="pun">+</span><span class="pln"> </span><span class="str">' - '</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> event</span><span class="pun">.</span><span class="pln">url</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> iabLoadError</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
alert</span><span class="pun">(</span><span class="pln">event</span><span class="pun">.</span><span class="pln">type </span><span class="pun">+</span><span class="pln"> </span><span class="str">' - '</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> event</span><span class="pun">.</span><span class="pln">message</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> iabClose</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
alert</span><span class="pun">(</span><span class="pln">event</span><span class="pun">.</span><span class="pln">type</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">removeEventListener</span><span class="pun">(</span><span class="str">'loadstart'</span><span class="pun">,</span><span class="pln"> iabLoadStart</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">removeEventListener</span><span class="pun">(</span><span class="str">'loadstop'</span><span class="pun">,</span><span class="pln"> iabLoadStop</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">removeEventListener</span><span class="pun">(</span><span class="str">'loaderror'</span><span class="pun">,</span><span class="pln"> iabLoadError</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">removeEventListener</span><span class="pun">(</span><span class="str">'exit'</span><span class="pun">,</span><span class="pln"> iabClose</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="com">// device APIs are available</span><span class="pln">
</span><span class="com">//</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> onDeviceReady</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
iabRef </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'loadstart'</span><span class="pun">,</span><span class="pln"> iabLoadStart</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'loadstop'</span><span class="pun">,</span><span class="pln"> iabLoadStop</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">removeEventListener</span><span class="pun">(</span><span class="str">'loaderror'</span><span class="pun">,</span><span class="pln"> iabLoadError</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'exit'</span><span class="pun">,</span><span class="pln"> iabClose</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="tag"></script></span><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span></span></code></pre>
<h1> </h1>
<blockquote>
<p> <code>InAppBrowser</code> 。</p>
</blockquote>
<pre><code><span class="kwd">ref</span><span class="pun">.</span><span class="pln">close</span><span class="pun">();</span><span class="pln">
</span></code></pre>
<ul>
<li><strong>ref</strong>: <code>InAppBrowser</code> <em>(InAppBrowser)</em></li>
</ul>
<h2> </h2>
<ul>
<li>Android </li>
<li> </li>
<li>iOS</li>
<li>Windows Phone 7 8</li>
</ul>
<h2> </h2>
<pre><code><span class="kwd">var</span><span class="pln"> </span><span class="kwd">ref</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">ref</span><span class="pun">.</span><span class="pln">close</span><span class="pun">();</span><span class="pln">
</span></code></pre>
<h2> </h2>
<pre><code><span class="dec"><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"><title/></span><span class="pln">InAppBrowser</span><span class="pln">.close Example</span><span class="tag"/><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"cordova.js"</span><span class="tag">></script></span><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="tag">></span><span class="pln">
</span><span class="com">// Wait for device API libraries to load</span><span class="pln">
</span><span class="com">//</span><span class="pln">
document</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">"</span><span class="str">deviceready</span><span class="str">"</span><span class="pun">,</span><span class="pln"> onDeviceReady</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
</span><span class="com">// device APIs are available</span><span class="pln">
</span><span class="com">//</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> onDeviceReady</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> ref </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
</span><span class="com">// close </span><span class="com">InAppBrowser</span><span class="com"> after 5 seconds</span><span class="pln">
setTimeout</span><span class="pun">(</span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
ref</span><span class="pun">.</span><span class="pln">close</span><span class="pun">();</span><span class="pln">
</span><span class="pun">},</span><span class="pln"> </span><span class="lit">5000</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="tag"></script></span><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span></span></code></pre>
<h1> </h1>
<blockquote>
<p> InAppBrowser 。 , InAppBrowser 。</p>
</blockquote>
<pre><code><span class="kwd">ref</span><span class="pun">.</span><span class="pln">show</span><span class="pun">();</span><span class="pln">
</span></code></pre>
<ul>
<li><strong>ref:</strong> InAppBrowser ( <code>InAppBrowser</code>)</li>
</ul>
<h2> </h2>
<ul>
<li>Android </li>
<li> </li>
<li>iOS</li>
</ul>
<h2> </h2>
<pre><code><span class="kwd">var</span><span class="pln"> </span><span class="kwd">ref</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'hidden=yes'</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">ref</span><span class="pun">.</span><span class="pln">show</span><span class="pun">();</span><span class="pln">
</span></code></pre>
<h2> </h2>
<pre><code><span class="dec"><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"><title/></span><span class="pln">InAppBrowser</span><span class="pln">.show Example</span><span class="tag"/><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"cordova.js"</span><span class="tag">></script></span><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="tag">></span><span class="pln">
</span><span class="com">// Wait for Cordova to load</span><span class="pln">
</span><span class="com">//</span><span class="pln">
document</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">"</span><span class="str">deviceready</span><span class="str">"</span><span class="pun">,</span><span class="pln"> onDeviceReady</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
</span><span class="com">// Cordova is ready</span><span class="pln">
</span><span class="com">//</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> onDeviceReady</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> ref </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'hidden=yes'</span><span class="pun">);</span><span class="pln">
ref</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'loadstop'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
alert</span><span class="pun">(</span><span class="str">'background window loaded'</span><span class="pun">);</span><span class="pln">
</span><span class="pun">});</span><span class="pln">
</span><span class="com">// close </span><span class="com">InAppBrowser</span><span class="com"> after 5 seconds</span><span class="pln">
setTimeout</span><span class="pun">(</span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
ref</span><span class="pun">.</span><span class="pln">close</span><span class="pun">();</span><span class="pln">
</span><span class="pun">},</span><span class="pln"> </span><span class="lit">5000</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="tag"></script></span><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span></span></code></pre>
<h1>executeScript</h1>
<blockquote>
<p> JavaScript <code>InAppBrowser</code> </p>
</blockquote>
<pre><code><span class="kwd">ref</span><span class="pun">.</span><span class="pln">executeScript</span><span class="pln"> </span><span class="pun"> </span><span class="pun"> </span><span class="pun"> )</span><span class="pln"> </span><span class="pun">;</span><span class="pln">
</span></code></pre>
<ul>
<li> <p><strong>ref</strong>: <code>InAppBrowser</code> 。<em>() InAppBrowser</em></p> </li>
<li> <p><strong>injectDetails</strong>: <code>file</code> <code>code</code> 。<em>( )</em></p>
<ul>
<li><strong> </strong>: URL 。</li>
<li><strong> </strong>: 。</li>
</ul></li>
<li> <p><strong> </strong>: JavaScript 。</p>
<ul>
<li> <code>code</code> , , , <code>Array</code> 。 , 。</li>
</ul></li>
</ul>
<h2> </h2>
<ul>
<li>Android </li>
<li> </li>
<li>iOS</li>
</ul>
<h2> </h2>
<pre><code><span class="kwd">var</span><span class="pln"> </span><span class="kwd">ref</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">ref</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'loadstop'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">ref</span><span class="pun">.</span><span class="pln">executeSript</span><span class="pun">({</span><span class="pln">file</span><span class="pun">:</span><span class="pln"> </span><span class="str">"myscript.js"</span><span class="pun">});</span><span class="pln">
</span><span class="pun">});</span><span class="pln">
</span></code></pre>
<h2> </h2>
<pre><code><span class="dec"><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"><title/></span><span class="pln">InAppBrowser</span><span class="pln">.</span><span class="pln">executeScript</span><span class="pln"> Example</span><span class="tag"/><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"cordova.js"</span><span class="tag">></script></span><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="tag">></span><span class="pln">
</span><span class="com">// Wait for device API libraries to load</span><span class="pln">
</span><span class="com">//</span><span class="pln">
document</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">"</span><span class="str">deviceready</span><span class="str">"</span><span class="pun">,</span><span class="pln"> onDeviceReady</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
</span><span class="com">// Global </span><span class="com">InAppBrowser</span><span class="com"> reference</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> iabRef </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">;</span><span class="pln">
</span><span class="com">// Inject our custom JavaScript into the </span><span class="com">InAppBrowser</span><span class="com"> window</span><span class="pln">
</span><span class="com">//</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> replaceHeaderImage</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">executeScript</span><span class="pun">({</span><span class="pln">
code</span><span class="pun">:</span><span class="pln"> </span><span class="str">"var img=document.querySelector('#header img'); img.src='http://cordova.apache.org/images/cordova_bot.png';"</span><span class="pln">
</span><span class="pun">},</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
alert</span><span class="pun">(</span><span class="str">"Image Element Successfully Hijacked"</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> iabClose</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">removeEventListener</span><span class="pun">(</span><span class="str">'loadstop'</span><span class="pun">,</span><span class="pln"> replaceHeaderImage</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">removeEventListener</span><span class="pun">(</span><span class="str">'exit'</span><span class="pun">,</span><span class="pln"> iabClose</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="com">// device APIs are available</span><span class="pln">
</span><span class="com">//</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> onDeviceReady</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
iabRef </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'loadstop'</span><span class="pun">,</span><span class="pln"> replaceHeaderImage</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'exit'</span><span class="pun">,</span><span class="pln"> iabClose</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="tag"></script></span><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span></span></code></pre>
<h1>insertCSS</h1>
<blockquote>
<p> CSS <code>InAppBrowser</code> 。</p>
</blockquote>
<pre><code><span class="kwd">ref</span><span class="pun">.</span><span class="pln">insertCSS</span><span class="pun">(</span><span class="pln">details</span><span class="pun">,</span><span class="pln"> callback</span><span class="pun">);</span><span class="pln">
</span></code></pre>
<ul>
<li> <p><strong>ref</strong>: <code>InAppBrowser</code> <em>(InAppBrowser)</em></p> </li>
<li> <p><strong>injectDetails</strong>: <code>file</code> <code>code</code> 。<em>( )</em></p>
<ul>
<li><strong> </strong>: URL 。</li>
<li><strong> </strong>: 。</li>
</ul></li>
<li> <p><strong> </strong>: CSS 。</p> </li>
</ul>
<h2> </h2>
<ul>
<li>Android </li>
<li> </li>
<li>iOS</li>
</ul>
<h2> </h2>
<pre><code><span class="kwd">var</span><span class="pln"> </span><span class="kwd">ref</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">ref</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'loadstop'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">ref</span><span class="pun">.</span><span class="pln">insertCSS</span><span class="pun">({</span><span class="pln">file</span><span class="pun">:</span><span class="pln"> </span><span class="str">"mystyles.css"</span><span class="pun">});</span><span class="pln">
</span><span class="pun">});</span><span class="pln">
</span></code></pre>
<h2> </h2>
<pre><code><span class="dec"><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"><title/></span><span class="pln">InAppBrowser</span><span class="pln">.</span><span class="pln">insertCSS</span><span class="pln"> Example</span><span class="tag"/><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"cordova.js"</span><span class="tag">></script></span><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="tag">></span><span class="pln">
</span><span class="com">// Wait for device API libraries to load</span><span class="pln">
</span><span class="com">//</span><span class="pln">
document</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">"</span><span class="str">deviceready</span><span class="str">"</span><span class="pun">,</span><span class="pln"> onDeviceReady</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
</span><span class="com">// Global </span><span class="com">InAppBrowser</span><span class="com"> reference</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> iabRef </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">;</span><span class="pln">
</span><span class="com">// Inject our custom CSS into the </span><span class="com">InAppBrowser</span><span class="com"> window</span><span class="pln">
</span><span class="com">//</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> changeBackgroundColor</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">insertCSS</span><span class="pun">({</span><span class="pln">
code</span><span class="pun">:</span><span class="pln"> </span><span class="str">"body { background: #ffff00"</span><span class="pln">
</span><span class="pun">},</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
alert</span><span class="pun">(</span><span class="str">"Styles Altered"</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> iabClose</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">removeEventListener</span><span class="pun">(</span><span class="str">'loadstop'</span><span class="pun">,</span><span class="pln"> changeBackgroundColor</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">removeEventListener</span><span class="pun">(</span><span class="str">'exit'</span><span class="pun">,</span><span class="pln"> iabClose</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="com">// device APIs are available</span><span class="pln">
</span><span class="com">//</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> onDeviceReady</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
iabRef </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'loadstop'</span><span class="pun">,</span><span class="pln"> changeBackgroundColor</span><span class="pun">);</span><span class="pln">
iabRef</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'exit'</span><span class="pun">,</span><span class="pln"> iabClose</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="tag"></script></span><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span></span></code></pre>
<h1>InAppBrowserEvent</h1>
<p> <code>addEventListener</code> <code>InAppBrowser</code> 。</p>
<h2> </h2>
<ul>
<li> <p><strong> </strong>: eventname, <code>loadstart</code> , <code>loadstop</code> , <code>loaderror</code> , <code>exit</code> 。<em>( )</em></p> </li>
<li> <p><strong>url</strong>: URL。<em>( )</em></p> </li>
<li> <p><strong> </strong>: <code>loaderror</code> 。<em>( )</em></p> </li>
<li> <p><strong> </strong>: , <code>loaderror</code> 。<em>( )</em></p> </li>
</ul>
<h1>window.open</h1>
<p> URL <code>InAppBrowser</code> , 。</p>
<pre><code><span class="kwd">var</span><span class="pln"> </span><span class="kwd">ref</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="pln">url</span><span class="pun">,</span><span class="pln"> target</span><span class="pun">,</span><span class="pln"> options</span><span class="pun">);</span><span class="pln">
</span></code></pre>
<ul>
<li> <p><strong>ref</strong>: <code>InAppBrowser</code> 。<em>() InAppBrowser</em></p> </li>
<li> <p><strong>url</strong>: <em>( )</em> URL。 <code>encodeURI()</code> URL Unicode 。</p> </li>
<li> <p><strong> </strong>: URL, , <code>_self</code> 。<em>( )</em></p>
<ul>
<li><code>_self</code>: web URL , <code>InAppBrowser</code>.</li>
<li><code>_blank</code>: <code>InAppBrowser</code>.</li>
<li><code>_system</code>: web 。</li>
</ul></li>
<li> <p><strong> </strong>: <code>InAppBrowser</code> 。 , : <code>location=yes</code> 。<em>( )</em></p> <p><code>options</code> , / 。 。 :</p>
<ul>
<li> <p><strong> </strong>: <code>yes</code> <code>no</code> , <code>InAppBrowser</code> 。</p> <h2>Android </h2> </li>
<li> <p><strong>closebuttoncaption</strong> - , " " 。 </p> </li>
<li><strong> </strong>- , 。 Load 。 ( ), , 。 </li>
<li><strong>clearcache</strong> - 'yes' cookie </li>
<li> <p><strong>clearsessioncache</strong> - 'yes' cookie </p> <h2>iOS </h2> </li>
<li> <p><strong>closebuttoncaption</strong> - , " " 。 。</p> </li>
<li><strong> </strong>- , 。 Load 。 ( ), , 。 </li>
<li><strong> </strong>- ' ' ' ', InAppBrowser ( )</li>
<li><strong>enableViewportScale</strong>: <code>yes</code> <code>no</code> , meta ( <code>no</code>).</li>
<li><strong>mediaPlaybackRequiresUserAction</strong>: <code>yes</code> <code> no</code> , HTML5 autoplaying ( <code>no</code>).</li>
<li><strong>allowInlineMediaPlayback</strong>: <code>yes</code> <code>no</code> HTML5 , , 。 HTML <code>video</code> <code>webkit-playsinline</code> ( <code>no</code>)</li>
<li><strong>keyboardDisplayRequiresUserAction</strong>: <code>yes</code> <code> no</code> , JavaScript <code>focus()</code> ( <code>yes</code>).</li>
<li><strong>suppressesIncrementalRendering</strong>: <code>yes</code> <code> no</code> , ( <code>no</code>).</li>
<li><strong>presentationstyle</strong>: <code>pagesheet</code> , <code>formsheet</code> <code>fullscreen</code> ( <code>fullscreen</code>).</li>
<li><strong>transitionstyle</strong>: <code>fliphorizontal</code> , <code>crossdissolve</code> <code>coververtical</code> ( <code>coververtical</code>).</li>
</ul></li>
</ul>
<h2> </h2>
<ul>
<li>Android </li>
<li> </li>
<li>iOS</li>
<li>Windows Phone 7 8</li>
</ul>
<h2> </h2>
<pre><code><span class="kwd">var</span><span class="pln"> </span><span class="kwd">ref</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> ref2 </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="pln">encodeURI</span><span class="pun">(</span><span class="str">'http://ja.m.wikipedia.org/wiki/ハングル'</span><span class="pun">),</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
</span></code></pre>
<h2> </h2>
<pre><code><span class="dec"><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"><title/></span><span class="pln">window.open</span><span class="pln"> Example</span><span class="tag"/><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"cordova.js"</span><span class="tag">></script></span><span class="pln">
</span><span class="tag"><script><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="tag">></span><span class="pln">
</span><span class="com">// Wait for device API libraries to load</span><span class="pln">
</span><span class="com">//</span><span class="pln">
document</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">"</span><span class="str">deviceready</span><span class="str">"</span><span class="pun">,</span><span class="pln"> onDeviceReady</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
</span><span class="com">// device APIs are available</span><span class="pln">
</span><span class="com">//</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> onDeviceReady</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="com">// external url</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> ref </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="pln">encodeURI</span><span class="pun">(</span><span class="str">'http://apache.org'</span><span class="pun">),</span><span class="pln"> </span><span class="str">'_blank'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'location=yes'</span><span class="pun">);</span><span class="pln">
</span><span class="com">// relative document</span><span class="pln">
ref </span><span class="pun">=</span><span class="pln"> </span><span class="pln">window</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">'next.html'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_self'</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="tag"></script></span><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span><span class="tag"/><span class="pln">
</span></span></code></pre>
</div>
</div>
</div>
</div>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Vuejs + Cordova 개발을 vue-cli를 사용하여 몇 가지 명령으로 시도 할 수있는 플러그인을 작성했습니다.Vue-CLI3.0과 호환되는 Cordova 용 플러그인을 만들었습니다. 아직 베타이지만 최소한 움직입니다. 사전에 설치 및 이 필요합니다 그 외 플랫폼에 대해서 등, 좀 더 자세한 내용을 에 썼습니다. npm ru...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.