【问题标题】:Possible to redirect using only webpage?可以仅使用网页重定向吗?
【发布时间】:2009-04-13 15:53:08
【问题描述】:

我有一个 UIWebView,它通过 viewDidLoad 中的 loadRequest 加载 URL。用户单击 RootViewController 中的一个按钮,该按钮会推送 webview 并出现一个网页。只能访问网页代码,有没有办法重定向用户?我尝试了 META Refresh,但没有任何影响。

链接不起作用,因为在 webview 中没有实现 webview 委托方法。我现在试图避免发布应用程序的更新。

【问题讨论】:

    标签: iphone cocoa-touch uiwebview


    【解决方案1】:

    1) 再次检查元刷新语法:

    <head>
    <meta http-equiv="refresh" content="0; URL=http://www.example.com/page123.html" />
    </head>
    

    2) 你说你可以访问网页代码,这能走多远?你能操纵http-header吗,如果是php-page,这是可能的:

    <?php
    header("Location: http://www.example.com/page123.html"); /* Redirect browser */
    
    /* Make sure that code below does not get executed when we redirect. */
    exit;
    ?>
    

    示例取自http://de.php.net/header

    其他服务器端语言应该有类似的东西。

    3) 使用javascript:

    window.location = 'http://www.example.com/page123.html';
    

    【讨论】:

    • 我需要延迟刷新元数据。显然这是一个 UIWebView 的事情。在移动 Safari 和桌面上运行良好。我没有实现任何 UIWebView 方法,所以我猜这就是它在我的应用程序中不起作用的原因。
    【解决方案2】:

    使用javascript:

    window.location = 'http://stackoverflow.com/questions/744329/possible-to-redirect-using-only-webpage';
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-20
      • 1970-01-01
      • 2017-08-09
      • 1970-01-01
      • 2013-09-27
      • 2023-03-11
      • 1970-01-01
      相关资源
      最近更新 更多