FB-Root Is Null, but only Sometimes in Firefox and IE - php

I have a Facebook Login Button on a login.php page on my website, and when its there it works like it should. But for some reason when I have a click on a link to this login.php the button doesn't appear. When I refresh the page, the button pops up. When I manually go to login.php the button appears every time.
This seems to only happen in Firefox (mac), I can't replicate the issue in Chrome. Firebug gives me this error, but it shows up even when the button loads:
document.getElementById("fb-root") is null
My Button rendering code looks like this:
<fb:login-button onclick="trainer()" perms="read_stream,email,publish_stream,offline_access,user_checkins,friends_checkins"></fb:login-button>
<div id="fb-root"> </div>
I have the FB.init code inside a script tag AFTER the body tag.
UPDATE: I've actually just confirmed that the same error pops up in IE8 on Windows.
Any advice could help thank you!

You might review a post by Gil Goldshlager to see if you have everything set up correctly.
One thing he points out is that you have to have your html tag set up correctly as follows:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en" lang="en">

Related

How to Visit a Site in Cron and Follow HTML Meta Redirects

Is there a way/tool to visit a site in cron that is capable of following HTML Meta Tag Redirects?
A programmer wrote a feature that when hit through a browser returns
<html>
<head>
<!-- HTML meta refresh URL redirection -->
<meta http-equiv="refresh"
content="0; url='.$base_url.'/cache/'.($trip_index+1).'">
</head>
<body>
<p>The page has moved to:
'.$base_url.'/cache/'.($trip_index+1).'</p>
</body>
</html>';
In a browser that will take you from example.com/cache/1 to example.com/cache/2 automatically until all the steps are done. Then the client came back and also wanted it to be automated...
I can't use cURL even with the -L flag because it only follows redirects in headers like 301, not the HTML ones.
I then found out about links and that worked great from the CLI with something like links -html-auto-refresh 1 example.com/cache and finished to the end. But unfortunately it doesn't work in cron because the refresh is part of the rendering itself.
So is there a tool that will work from a cron task that will do this? Browser testing tools? Selenium? PhantomJS? Splash?

IE not loading properly only the first time

I have an application that works perfectly in Chrome,Firefox and Safari, but when I load it on IE happens a strange thing: all the page is loaded on the left side and after one or two refresh it loads properly.
Here are two descriptive images:
And the second time (after one or more refresh) IE loads it like this:
Does anyone know why is IE having this behaviour?
Thank you.
I found the problem, it was quite simple.
I was calling my 'functions.php' as the very first code line (even before <!DOCTYPE html...). This file includes some javascripts function that CAN'T be loaded before <!DOCTYPE html (better between <head></head> tags).
Once I placed them between <head> tags the page is loading properly.
Thank you for the hints.

Allow switch from mobile site to full site with jquery

I have done some digging out here and am still a little unsure how to accomplish this. Here is the scenario:
I have a full HTML site that calls the following PHP code:
<?php
require_once('inc/mobile_device_detect.php');
mobile_device_detect(true,true,true,true,true,true,true,'mobile/',false);
?>
<!DOCTYPE html>
<html lang="en">
<head>blah blah</head>
etc...
The mobile_device_detect.php is a small library from http://detectmobilebrowsers.mobi/
So when I go to the full site from my mobile phone, the redirect happens perfectly. Next, on the mobile/index.html I have the following redirect code for those users that are wanting to see the full site (I should also mention that this mobile site uses jquery-mobile):
<img src="images/icons/world.png" width="32" height="32" alt="Full Site" class="ui-li-icon">Full Site
When I click this link, I am resent back to the mobile page. I know this is happening because the redirect script is being fired again. I have tested this by visiting the mobile site with a desktop client and the redirect occurs perfectly.
Any ideas how I can remedy this for mobile users wanting to see the 'full site'?
You can append a query param on your href like href="../index.html?full=true" in your main page check that full param is not present.
<?php
if (!isset($_GET['full'])) {
require_once('inc/mobile_device_detect.php');
mobile_device_detect(true,true,true,true,true,true,true,'mobile/',false);
}
?>

How does phpinfo() change the title of the page permanently?

If you use phpinfo() in your page, you will notice it will change the title of your page? And even if you give the title of your page to be different it will not change. How is this done?
Is because phpinfo print <title>, is depend on how browser handle the tag rendering.
Chrome, Firefox and internet explorer is practicing FIFO.
So, do this
<title>my title</title>
<?phpinfo() ?>
is my title being set as browser page title
<?phpinfo() ?>
<title>my title</title>
Then above will set page title to phpinfo()
phpinfo outputs a complete HTML page, including a <head> section with <title>phpinfo()</title>. You can only have one <head> and one <title> per page, so I wouldn't even know how you'd attempt to change the title to anything else without producing a completely broken page to begin with.
put <title> tag above phpinfo(). Check the page source there will be two title tags , first one will be shown.

Meta page refresh not working for php page?

i am trying to redirect users without javascript enabled to our help page (help.php), specifically the part that talks about enabling javascript (help.php#nojavascript).
however, my meta refresh is not working! it keeps on refreshing the same page! i tried redirecting to a different page with a .html extension instead, and that works, so why doesn't this work?
...
</script>
<!-- if user doesn't have JS enabled, take them to help page -->
<noscript>
<meta http-equiv="Refresh" content="3;url=help.php" />
</noscript>
</head>
...
Try to use an absolute path:
<META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.some.org/some.html">
For one thing, try taking it out of the NOSCRIPT element. Browsers with scripting enabled are supposed to ignore everything inside NOSCRIPT.
i was including a file that redirected the user to home.php =( sorry!

Categories