4thSpace
4thSpace

Reputation: 44310

Possible to redirect using only webpage?

I have a UIWebView that loads a URL through loadRequest in viewDidLoad. The user clicks a button in the RootViewController, which pushes the webview and a webpage appears. With only access to the webpage code, is there a way to redirect the user? I tried the META Refresh but that didn't have any affect.

Links won't work since none of the webview delegate methods are implemented in the webview. I'm trying to avoid releasing an update of the app for now.

Upvotes: 1

Views: 584

Answers (2)

user89021
user89021

Reputation: 15162

1) Check again the meta refresh syntax:

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

2) You said you have access to the webpage code, how far does this go? Can you manipulate the http-header, in case of a php-page this is possible:

<?php
header("Location: http://www.example.com/page123.html"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>

Example taken from http://de.php.net/header

Other server side languages should have something similar.

3) Use javascript:

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

Upvotes: 2

cgp
cgp

Reputation: 41381

Use javascript:

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

Upvotes: 1

Related Questions