I'm having a problem implementing the feed dialog function of Facebook within my canvas page.
The following code runs after the form is successfully submitted to the MySQL database.
header("Location: https://www.facebook.com/dialog/feed?
app_id=************&
link=".$applink."&
picture=".$apppicture."&
name=".$appname."&
caption=".$appcaption."&
description=".$appdescription."&
redirect_uri=".$redirecturi);
It loads the following:
Ideally I need the header to redirect the location to the _parent frame. I've tried implementing this using Javascript, and a secondary header specifying target preceding the location header - but neither of these methods worked.
I just need some way of either:
1) Not showing the top bar.
2) Hiding it using a CSS hack
Any ideas?
Thanks,
Phil
Of course the JavaScript method works – if I doesn’t for you, then you simply did it wrong.
Output something like the following in answer to the form submit, and no HTTP location header with it:
<script>
window.top.location.href = '…the URL you want the user “redirected” to …';
</script>
Surround it by a basic HTML document structure, if you like – but put nothing else in there, like actual data the user is supposed to read.
I've tried implementing this using [...] a secondary header specifying target preceding the location header - but neither of these methods worked.
There is no “target” for HTTP location headers. You can’t get stuff working by just inventing your own imaginary syntax …
Related
I need to pass parameters and an anchor in a php program to make sure the cursor is positioned at the last place it was in the page when it returns.
program.php?ID=123&ID2=456#777
ID=123
ID2=456
html anchor is #777
Can someone tell me how to make this work? Since it isn't working the way I'm doing it now. Thanks
The browser will not send the anchor to web server.
So PHP can't get the anchor from url.
maybe you can use javascript to request program.php?ID=123&ID2=456&anchor=777, then you can get the anchor by $_GET['anchor'].
Sorry for my bad english (ㄒoㄒ).
If you want force the cursor to the position.
this code will redirect to http://website.com/page.php#anchor and the broswer will auto cursor the position.
<?php
header("location: http://website.com/page.php#anchor");
exit;
warning: take care about header function, there is the manual header function
If the current page is the same as the redirect page, above the code will infinite redirect and the browser will throw error. So you have to write some logic, make it redirect when you want. Or just write two different page, one to show content, other one redirect to content page with anchor.
But I still think it is better to do that by JavaScript.
Currently I have subdomain.mydomain.com, which redirects to mydomain.com/subdomain(I am using a PHP - codeigniter framework).
But all I want is after redirection url should remain subdomain.mydomain.com instead of mydomain.com/subdomain.
Is there any way to achieve this?
if you like to keep it pure html + php, i suggest you look into the iframe tag from html.
it is basically a browser window within your current browser window. Set the iframe to cover up 100% of your current browser window and set it's url to mydomain.com/subdomain.
what you'll see is that it's displaying content from mydomain.com/subdomain but your url field in your main browser is still saying subdomain.mydomain.com
Write this code in the routes.php file(present in config folder):
$route['mydomain.com/subdomain'] = "subdomain.mydomain.com";
Basically it's logic is
$route['route_you_want_to_show'] = "current_route";
But mind well in codeigniter routes are formed from the redirection of code to controller and its methods.
I need some help to better understand SEO with ajax loaded content.
Here the context:
I have a single.php where content is dynamically generated (with php and an xml database) for each single post.
I load a container of this single.php inside my index.php page via ajax.
Here the working script:
$.ajaxSetup({cache:false});
$(".phplink").click(function(){
var post_link = $(this).attr("href");
window.location.hash = "!"+ post_link ;
$("#ajaxify_container").html("loading...");
$("#ajaxify_container").load('single.php?blog_no='+post_link+' #container');
return false;
});
$(window).hashchange( function(){
var hash = window.location.hash;
var hash = location.hash.replace("#!","");
if(hash != '') {
var post_link = hash;
$("#ajaxify_container").html("loading...");
$("#ajaxify_container").load('single.php?blog_no='+post_link+' #container');
}
else {
$.get(hash, function (data) {
$("#ajaxify_container").html('');
});
}
});
$(window).hashchange();
An example of a link in index.php (when I click on a link I've got in url website.com/#!12) :
<a class="phplink" href="12">Post 12</a>
And in my .htaccess file I added this lines to rewrite properly the url:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /([0-9]+)$ /single.php?blog_no=$1
Everything works fine... (by the way, my single.php is SEO friendly "alone" and works without javascript)
However, by using ajax like this, with dynamic php page, is it still SEO friendly?
I know that ajax is difficult to be crawled. What is the best way to have a good (not the best, something correct) SEO with ajax content?
Regarding the structure of the link, I don't fully understand what google bot will crawl.
Because of the href="12", so the dynamic href="/single.php?blog_no=12".
In the web browser :
website.com/single.php?blog_no=12 and website.com/12 load only my single.php page
website.com/#!12 load my index.php page with a container loaded from website.com/single.php?blog_no=12
Of course I only want that google crawls the hashbang url...
(EDIT: if I open the link in a new tab with right click, it loads the single.php (that I don't want). It seems to be a normal behavior but...I want to prevent it)
Sorry for my English, I'm French.
Dynamically loaded content is generally hard to get right from an SEO perspective. Your description is a little confusing, but I think I have an idea of what you're looking for.
First of all, there are mainly two ways with which Google finds out about pages on your site:
A Sitemap (Google likes XML sitemaps) - A file that tells Google every page on your site to index
Links - Google will follow any internal link on pages it tries to index unless they are marked with rel="nofollow"
There's also links in and some other stuff, but for the purposes of this explanation...lets ignore those.
Anyway, unless you're explicitly telling Google that website.com/single.php?blog_no=12 exists, it's going to have a hard time finding it. To be honest, I'm not sure how Google will handle something like href="12", it may try to follow that link to website.com/12 which may effect your ranking if there is nothing there. So in the end, you might want to add rel="nofollow" to your AJAX trigger links.
A good way to handle AJAX and dynamically loaded content is to make sure fallbacks are in place, for example if you have something like href="single/12 set up to load some content with AJAX, you should also have a fallback page that doesn't use JS/AJAX. This ensures that both search engine bots, and users without Javascript can see that content if it otherwise wouldn't have been visible anywhere else.
Last small tidbit, if you test your links on something like http://www.dnsqueries.com/en/googlebot_simulator.php and they turn up with errors, or blank pages (search engine bots don't use javascript) you should nofollow those links, or setup fallback pages
Nevermind...this is the last thing. You should go a couple steps further with your htaccess rewrite to make your URLs completely clean of query strings. For example website.com/single/blog/12 is better than website.com/single.php?blog_no=12 for both SEO and users.
Okay, first off, I am not well-versed in JS or PHP. I can usually change an existing script around to do what I'd like, but not write something from scratch. Any URLs I mention in this for examples are made-up.
With that in mind, I am designing a page using a template that has CSS, PHP, and JS all of which I have really modified. Each page has a header, a nav bar, and a footer that are called with an include statement. I understand that part. However, on ONE of the pages, I would like to have a different nav-bar, and it won't change.
What I have noticed: The JS seems to change the clicked URLs from, say http://www.example.com/test.php to http://www.example.com/#test.php
What would be the purpose for that? Also... if I manually TAKE OUT the hashtag in the URL on the page that I want the new nav-bar, the new nav-bar shows! However, then if I switch pages, it'll make the end of the URL like ...test.php#newpage.php
So I either need to figure out how to modify this to NOT put the hashtag in the URL (but if there is a compelling reason for it, of course, it can stay), OR how to get that one page to show the alternate nav-bar. The alternate nav-bar is a table of contents, so the html has hashtags in it to direct users to specific parts of the page... could those hashtags in the html be conflicting somehow and that is why it won't show up, or??? GAH!
Any help would be appreciated.
Okay, here is part of the javascript... it is the only section where it looks like it is referring to # in the URL:
var $fadeWrapper = $("#fade-wrapper"),
$allNav = $("#main-nav a"),
$allListItems = $("#main-nav li"),
url = '',
liClass = '',
hash = window.location.hash,
$ajaxLoader = $("#ajax-loader");
$("body").attr("id", "");
if (hash) {
hash = hash.substring(1);
liClass = hash.substring(0,hash.length-4);
url = hash + " #inside-content";
$fadeWrapper.load(url);
$("." + liClass).addClass("active");
} else {
$("#main-nav li:first").addClass("active");
}
*UPDATE: I have decided to just remove the javascript altogether. In doing some reading, I have come to the conclusion that the hashtag is there just so the script can tell which page is active, in order for the CSS to highlight one of the items in the navbar. It also has something to do with the animated gif that would show when you navigate pages. Neither one of those items are important enough for me to pull more of my hair out trying to figure out this stuff :D Thank you for your suggestions, though! *
The hash tags are added most likely because the links you are clicking have an href value of #.
Couldn't you just create a new header file (if that is where the navbar code is), modify the navbar how you want in that header file, and include the new file instead of the current header on the page where you want the different navbar?
I have an iFrame that does some background processing. When this processing is complete I would like to re-direct the user to another page, but the header change code is only affecting the embedded iFrame. Is there a way to target the main window?
I have seen the deprecated Meta redirect have a target attribute, but I don't know how widely it is supported.
In Javascript:
top.location.href = "resultpage.htm";
Works only if the top frame is on the same domain as the emitting page.
For a solution that works across domains and without Javascript, the following would work:
Continue
Use JavaScript to track content of frame, if content change, redirect browser :)
We can use javascript like this:
target.window.location='locationpage.php';
parent.window.location='index.php';
For me this always works without fail, have tried many of the others but there always seems to be some sort of issue....and it does not matter if headers have been sent etc.....
<?php
echo "<script>window.location = 'http://www.google.com'</script>";
?>
Remember this goes at the very bottom