【问题标题】:how to open a link in a view for phonegap?如何在phonegap的视图中打开链接?
【发布时间】:2012-04-09 06:01:22
【问题描述】:

我想在视图中打开一个链接,例如 http://google.com 。我用 iframe src="" 试过,但是当我在 iphone 上运行它时,它会在 webview 中打开,所以我看不到页眉和页脚。

 <div data-role="view" data-layout="overview-layout" data-title="More">    
    <div data-role="content" >
        <div class="km-scroll-container" > 
            <ul id="menuList" class="item-list km-listview km-listgroup">
                <li>
                    <ul data-role="listview">
                        <li><a class="details-link" data-role="listview-link" href="">xxx</a></li>
                          <li><a class="details-link" data-role="listview-link" href="#moreinfo">yyy</a></li>

                        <li></li>

                    </ul>
                </li>
            </ul>
        </div>
    </div>        
</div>

    <div data-role="view" data-layout="overview-layout" id="moreinfo" data-title="More Info">   
    <div data-role="content">
        <div class="km-scroll-container">
           <iframe width="100%" height="100%" frameborder="0" scrolling="no" marginheight="0"
                marginwidth="0" src="http://www.google.com">
            </iframe>    
        </div>
    </div>

当我打开此页面时,它会直接在 web 视图中打开 google,我的意图是在单击“yyy”时打开。我也需要它在 iphone 上运行。

【问题讨论】:

标签: iframe cordova kendo-ui


【解决方案1】:

下载 url 的内容并点击按钮加载视图

    NSData *d = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com"]];
    NSString *s = [[NSString alloc] initWithData:d encoding:NSUTF8StringEncoding];
    //load string s in view
    textView.text = s;

【讨论】:

  • 我不是 iphone 开发人员,需要它在 html 页面中工作并使用 kendoui。
【解决方案2】:

如果您可以使用 javascript,请尝试使用

window.open("www.google.com");

在您的 html 中将是:

<iframe width="100%" height="100%" frameborder="0" scrolling="no" marginheight="0"
                marginwidth="0" onclick="window.open("www.google.com")">

【讨论】:

  • onclick 属性未找到。在这里,如果我使用 onclick 作为锚点,它会很好地打开链接,但它会在新的 Web 视图中打开,而不是在我的页面中打开,该页面用页脚和页眉装饰。
猜你喜欢
  • 2014-07-20
  • 1970-01-01
  • 2019-07-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多