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.
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';
Use javascript:
window.location = 'http://stackoverflow.com/questions/744329/possible-to-redirect-using-only-webpage';
Related
I'm trying to do a simple mobile redirect on my site, but I'm getting the error in the title.
The redirect code is simply:
<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "http://bartlettstudio.com/mobile";
}
//-->
</script>
If you visit http://bartlettstudio.com on a phone, you can see that the redirect is indeed working and taking you to http://bartlettstudio.com/mobile, but that /mobile page isn't loading. It will hang and eventually time out and give you the error above.
I assume this is a server/dns setting of some kind, but I don't even know where to look.
Thanks for any suggestions!
Terry
Your script is redirecting the page back to itself. So the question is, why are you redirecting to the mobile page from the mobile page? Need to remove the code from the /mobile page or put something in place to keep it from activating.
I have SPA that uses hash-tag URLs for identifying content (#/resource/id), I've added like button and it works, but how do I specify thumbnail, description etc?
From what I've read I should use
<meta property="og:image" content="http://www.example.com/site/preview.png"/>
but I have a static page without any back end + I need to change it depending on which content is loaded. What should I do?
UPDATE: I've found answer: Facebook Like Button refresh after AJAX-Load
In order to make your meta tags dynamic you will need to use backend code, such as PHP or ASP.
There really is no other way to make the header of the document dynamic.
PHP example:
<?php
if(isset($_GET['myparam']) && $_GET['myparam']==='big'){
echo '<meta property="og:image" content="http://www.example.com/site/preview_big.png"/>';
}else{
echo '<meta property="og:image" content="http://www.example.com/site/preview_little.png"/>';
}
?>
You're going to have to find a way to pass in a good URL to your image. Facebook takes this tag, goes to your site, and gets your image.
PhoneGap is not able to open the internal link.In my html I am using href tag But unable to load the webpage..Can anyone please suggest how to redirect one html page to another html page in phonegap ?
You can try this.
Code ::
HTML
Next Page
Javascript
<script type="text/javascript">
function goToNext() {
window.location.href = './NextPage.html';
}
</script>
Hopefully, This will help you for navigating to a new page.
Thanks.
How About redirecting page automatically in iphone?
For example, i have used $.mobile.changePage("login.html"); based on jQuery Mobile, but the app just displays a blank page.
Whether to use $.mobile.changePage(); to redirect page in iphone?
It runs well in Android.
I've been working on a problem for the last day and a half now and have still yet to find a solution.
When visitng my game on facebook (which is in facebook's iFrame) php sessions don't work. This is for IE and Safari. Chrome works fine.
I've already read all the posts on stack about this problem, which seems to be down to third party cookie security and needing interaction with the iFrame first. There was a workaround by making javascript post some form data to the iFrame first, but this seems to have been 'fixed' in the latest versions of the browsers very recently as this no longer works.
I even tried implementing a start page that would require them to click a link first (in the iFrame) to load another page which would then create the session. But even THAT doesn't work.
I'm also having trouble even loading new pages in the iFrame using javascript, which seems to always cause infinite loop refreshes.
And no, P3P headers do NOT solve it.
Does anyone have a solution to this problem? I can't be the only one with it, considering how many facebook apps exist!
I came across this problem using a client that had "Accept third party cookies" disabled. My solution was to force PHP to embed the session ID into the URI by putting this line at the start of each page:
ini_set('session.use_trans_sid', true);
As the URLs are in iframe within Facebook the SID is not seen in the top window.
For IE, you will need the P3P Headers set. Something like:
<?php header('P3P: CP="CAO PSA OUR"'); ?>
Safari blocks 3rd-party cookies by default. Currently, the only work-around that is working for me is to "pop-up" a new window to set the cookies. I have something like this:
<script type="text/javascript">
function safariFix(){
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1){
window.open('https://yourdomainname.com/safari.php', 'Safari Fix','width=100,height=100');
}
}
</script>
And safari.php will have this:
<?php
setcookie("safari_test", "1");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Safari Fix</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
window.close();
});
</script>
<body>
Since Safari does not accept third-party cookies by default, we are forced to open this window.
This window will automatically close once we have set the cookies.
</body>
</html>
PROBLEM: This won't work if users have "block pop-ups" enabled in Safari. If anyone has a better solution for this, inform me ;)
I have developed a site that has urls to other sites. I would like to make it redirect but log the click on the redirection.
I tried to find the way facebook does this, just to learn and came with this code:
<html>
<body>
<script type="text/javascript">
/* <![CDATA[ */
document.location.replace($url);
/* ]]> */
</script>
<script type="text/javascript">
/* <![CDATA[ */
setTimeout("(new Image()).src='/laudit.php?r=JS&u%5Bprotocol%5D=http&u%5Bdomain%5D=www.youtube.com&u%5Bport%5D&u%5Bpath%5D=%2Fwatch&u%5Bquery%5D%5Bv%5D=uZ2sPofyjXc&u%5BrawQueryString%5D=v%3DuZ2sPofyjXc';",5000);
/* ]]> */</script>
</body>
My question is: what is the purpose to put a url inside an image source and inside a timeout?
I guess it's to call an audit page, using timeout to simulate a kind of async call to the page, and create a "ficticious" image, just to call the URL?
Encountered this one too, and got curious.
I believe they are just tracking the pages which loads slow or doesn't redirect correctly
if it takes more than 5 secs (5000) the laudit.php will execute, then they track it and do some back-end stuffs.
But if the javascript redirect script works within the time, the laudit tracker won't execute.
Maybe facebook is doing some more checks later on about the site, probably just some analytics or for performance purpose
I think laudit means link audit