无法使用inAppBrowser打开网址

时间:2013-09-10 18:00:58

标签: javascript xcode cordova

我现在已经在xcode中浏览了这个应用程序一段时间了。我已经构建了几个html页面并集成了inAppBrowser,因此url在设备默认浏览器中打开。这在我的所有其他页面上都很完美,但是当我尝试对这个特定页面做同样的事情时,网址永远不会打开?我觉得这是一个javascript错误,但我的JS知识充其量只是最小的。

如何使用inAppBrowser在这个特定页面上打开url,就像在其他页面上一样?没有什么不同,除了这个页面有自己的JS播放媒体。

非常感谢任何帮助。 THX

<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
            <meta name="viewport" content="width=device-width, user-scalable=no" />



        <!-- <link rel="stylesheet" href="css/index.css"> -->

        <title>My App</title>


        <style>
            * {
                -webkit-touch-callout: none;
                -webkit-user-select: none;
            }
            </style>



    </head>
    <body>


        <script type="text/javascript" src="cordova.ios.js"></script>


        <script type="text/javascript" charset="utf-8" src="video.js"></script>

        <script type="text/javascript">

            function playbeachcam(){
                document.getElementById('bankschanneldiv').style.display= "none";
                document.getElementById('beachcamdiv').style.display= "block";
                document.getElementById('looperscamdiv').style.display= "none";


               // window.plugins.videoPlayer.play("http://.../playlist.m3u8");
            }

            function playloopercam(){
                document.getElementById('bankschanneldiv').style.display= "none";
                document.getElementById('beachcamdiv').style.display= "none";
                document.getElementById('looperscamdiv').style.display= "block";


               // window.plugins.videoPlayer.play("http://.../playlist.m3u8");
            }

            function playbankcam(){
                document.getElementById('bankschanneldiv').style.display= "block";
                document.getElementById('beachcamdiv').style.display= "none";
                document.getElementById('looperscamdiv').style.display= "none";

                //window.plugins.videoPlayer.play("http://.../playlist.m3u8");
            }

            function openHome() {
                var ref = window.open('http://www.google.com/', '_blank', 'location=yes');
                ref.addEventListener('loadstart', function() { alert('start: ' + event.url); });
                ref.addEventListener('loadstop', function() { alert('stop: ' + event.url); });
                ref.addEventListener('exit', function() { alert(event.type); });
            }

            </script>



        <div class="header-container" data-role="header">


            <div style=" text-align:left;margin-left:15px;">
                <a href="index.html" style="text-decoration:none;"><img style="width: 59px; height: 50px" src="img/wbl-logo.png" />
                    <span style="width:auto;position:absolute;bottom:25%;margin-left:10px;font-size:22px;color:#07a54a;">My App</span></a>
            </div> <!-- end logo -->
            <div style="text-align:right;width:auto;position:absolute;right:5%;top:30%;">
                <a class="ui-btn ui-shadow ui-btn-corner-all ui-btn-inline ui-btn-up-c" data-inline="true" data-transition="slide" data-role="button" href="#menu" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-theme="c">
                    <span class="ui-btn-inner ui-btn-corner-all">
                        <span class="ui-btn-text" style="color:#0267a6;">MENU</span>
                    </span>
                </a>
            </div><!-- end menu -->

        </div><!-- end header -->

        <div class="content-container" data-role="content">

            <div id="wrapper" style="bottom:5px;">
                <div id="main-content">


                    <button id="BeachCam" onClick="playbeachcam();" >
                        Play Beach Cam
                    </button>
                    <br/>
                    <button id="LooperStar" onClick="playloopercam();">
                        Play Looper Cam
                    </button>
                    <br/>
                    <button id="BanksChannel" onClick="playbankcam();">
                        Play Banks Cam
                    </button>


                    <div id = "bankschanneldiv" style="display:none;">

                        <video
                            id="mediaplayer1"
                            controls="1"
                            autoplay="1"
                            height="218"
                            preload="none"
                            src="http://.../playlist.m3u8"
                            width="100%">
                        </video>

                    </div>
                    <div id = "beachcamdiv" style="display:none;">

                        <video
                            id="mediaplayer2"
                            controls="1"
                            autoplay="1"
                            height="218"
                            preload="none"
                            src="http://.../playlist.m3u8"
                            width="100%">
                        </video>

                    </div>
                    <div id = "looperscamdiv" style="display:none;">

                        <video
                            id="mediaplayer3"
                            controls="1"
                            autoplay="1"
                            height="218"
                            preload="none"
                            src="http://.../playlist.m3u8"
                            width="100%">
                        </video>

                    </div>





                    <p style="color:#f4f4f4;">Having Trouble?</p>
                    <p><a style="color:#07a54a;text-shadow:1px 1px 1px #333;" href="#" onclick='openHome()' target="_blank" >View the cams on our website</a></p>



                </div>
            </div>
        </div>

        <div class="footer ui-bar-a" data-role="footer" role="contentinfo">
            <div style="text-align:center;width:auto;margin:10px 0;">
                <a href="#" onclick='openHome()' target="_blank" style="text-decoration:none;color:#291e0f;">My Footer </a>
            </div> <!-- end footer content -->


        </div><!-- end footer -->


    </body>

</html>

1 个答案:

答案 0 :(得分:0)

经过进一步的故障排除后,我发现这就是问题所在:

<script type="text/javascript" src="cordova.ios.js"></script>

所以现在我找到了一个解决方案,所有问题都解决了。