I'm attempting to share a link on facebook via url. I get the share to work, however instead of loading the redirectURI, I want to close the popup window. My code:
function fb_share(url) { window.open(url,"share_window","width=400,height=300"); }
...
fb_share('http://www.facebook.com/dialog/feed?app_id=128000000000&link=http%3a%2f%2fwww.facebook.com%2fapps%2fapplication.php%3fid%128000000000%26sk%128000000000&picture=http://www.google.com/images/nav_logo83.png&name=name&description=description&redirect_uri=http%3a%2f%2fwww.facebook.com%2fapps%2fapplication.php%3fid%3d128398017257108%26sk%3dapp_128000000000&display=popup')
I wrote a page that can be used as the redirect_uri, which will close popup via javascript: http://www2.highpoint.edu/close_popup.php
View the source to see some simple HTML:
<!doctype html>
<html>
<h3>Thank you!</h3>
Close this window
<script type="text/javascript">
close();
</script>
</html>
It works when used as the callback from a Facebook Dialog.
Redirected url contains parameter post_id, so you can check on it and close window if you find it:
if (window.location.search.indexOf('post_id') == 1){
window.close();
}
Related
I don't want my webpage to open inside facebook. It doesn't function quite right.
Is there a way to list a url that when reached, redirects to my external site that is NOT is the facebook interface?
I have tried uploading a php file with a redirect in it, but it makes no difference.
<script type="text/javascript">
window.top.location.href = "http://aurumhairstylists.co.nz";
</script>
<p>If you are not automatically redirected here is a link to <a target="_blank" href="http://shereewalker.com">shereewalker.com</a>. Opens in a new tab or window.</p>
Any help would be great
Thanks
IT is possible but the browser would block the page as a action not "requested by the user".
this is a VERY simple implementation:
<script>
function myFunction() {
var myWindow = window.open("http://aurumhairstylists.co.nz", "myWindow", "width=400, height=200");
}
</script>
<IMG SRC="1x1.gif" ALT="" HEIGHT=1 WIDTH=1 onLoad="myFunction()">
cheers
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 ;)
As I understand it, Facebook's FBML should render html. But mine isn't. Here is my source code after viewing the page in the browser:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head id="Head1" runat="server"> <title>test</title>
</head>
<body onload="initFB();">
<script src="http://static.new.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"
type="text/javascript"></script>
<fb:login-button v="2" size="medium" onlogin="window.location='test.aspx'">Login with your Facebook account</fb:login-button>
<script type="text/javascript" language="text/javascript">
function initFB() {
FB_RequireFeatures(["XFBML"], function(){
FB.init("464 ... my api key here ... b62", "xd_receiver.htm");
});}
</script>
</body>
</html>
Here's the page: http://www.rebelstudent.com/test.aspx
Could it be the server? Is there any change that my host is blocking communication with Facebook somehow? Doesn't make sense because the facebook connect kinda works...the popup windows just doesn't go away. I'm pretty sure it's because these FBML tags aren't being rendered properly and so the "onlogin" function isn't getting called...
Anway, I'm new at this. Any help is appreciated because the facebook developer forums seem kind of dead.
I haven't done any work on Facebook so I don't have a direct answer for you, sorry. However, have you tried starting with a "Hello World" app? Basically remove everything that is not absolutely necessary for Facebook and try to display the text "Hello World" to the screen. Remove the script, the header, fb button, etc.
If you are able to get "Hello World" working, then just add small pieces of the application back in until it breaks. Then you will know exactly what it is that is breaking the output.
If you are not able to get "Hello World" to work, then you are missing a basic requirement. Perhaps somebody else will know what that is.
Well it looks like I need to always use "www" in front of my domain. That was my issue. rebelstudent.com/test.aspx doesn't work but www.rebelstudent.com/test.aspx does. Thanks for everyone's help!
More than likely the problem is your render method for your canvas is set to an IFrame (instead of FBML).
Go here: http://www.facebook.com/developers/apps.php
Click on 'Edit Settings'
Select 'Canvas' in the left navigation
Underneath the 'Canvas Settings' heading, select 'FBML' for the 'Render Method'
FB_RequireFeatures(["XFBML"], function() {
FB.Facebook.init("key", "/xd_receiver.htm");
FB.Connect.requireSession();
FB.ensureInit(function() {
FB.Connect.showPermissionDialog("offline_access,read_stream", function(x) { alert(x); window.location = "/myAuthorizeApp"; });
});
});
It doesn't do quite the same thing as you're trying to achieve, but I found I needed to require XFBML to get the the other JS functions to work properly, strange enough.. Also, look into rendering XFBML server side.
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';