facebook like button on my site only shows up after you refresh the page. does it have to do with all.js - facebook

I used code from
http://developers.facebook.com/docs/reference/plugins/like/
to add a like button on the site. I have the script tags right after the body as described and the div further down by my header, but when I load the page, the like button is not there. but if I hit refresh its there. my guess is that the all.js is taking too long to load and its missed somehow on the 1st load. on the 2nd refresh, I assume the js is cached and things work as expected.
any idea how to wait on this? I have tried putting the script in the head, at the bottom.

When you say "I have the script tags right after the body", do you mean outside of the body? If so, try putting it in side the body, but after all other element inside of the body.
<body> ...other code ...other code ...other code
<script>Put your script here</script>
</body>

Related

featherlight loading msg before getting ajax data

I have a typical link for which I would like to display the output in a popup window. To do that I'm using featherlight.
I would like to display some kind of a loading indicator until I get data from ajax call.
This is what I have tried:
function wait() {
document.querySelector('.featherlight-content').textContent='pls wait...';
}
<a href='../servlet/NavWarn?action=send' data-featherlight="ajax" data-featherlight-before-content="wait();">
If I do that, it only prints "pls wait..." and the ajax data doesn't appear ever.
If I remove the "data-featherlight-before-content" from the A tag, ajax data appears correctly, but until it does I get an empty window (which is what I would like to avoid).
I've also tried doing it at featherlight's css (something like content:"pls wait...") without luck.
Any ideas?
Thank you
Short answer: replace -content by -inner.
Details:
The featherlight-content div contains the close box, any other static elements (like the navigation in case of the gallery), and the actual content called featherlight-inner. If you obliterate it, you destroy the -inner div and that's the one that displays your content!
I'll improve the doc on this

TinyMCE get form content without using submit button

I'm trying to put TinyMCE on my website. I figured out how to get it to show up, but I'm lost on how to process the content. In their example, they just have a link that references the top of the page and clicking on it somehow magically causes their dump.php script to execute. I don't understand what's going on here. Here is the link:
http://www.tinymce.com/tryit/basic.php
The "Submit" button at the bottom is really a link in a span element with href="#". The form action is dump.php. I want to know how they configured this to run without an actual submit button. Any help in understanding this is greatly appreciated!
To Get Content From Tinymce You Can Use GetContent Method of Currently ActiveEditor Instance
tinyMCE.activeEditor.getContent();
method is used to getting Content .. to Set The Content
tinyMCE.activeEditor.setContent("I Want Text To Be in Tinymce");
to find a perticular element in tinymce get body and find element
var body = tinyMCE.activeEditor.getBody();
$(body).find("#elem_id")
to get a full html
tinyMCE.activeEditor.getDoc().documentElement.innerHTML
hope that helps ..
Since I use PHP, I found this which is also useful:
http://www.tinymce.com/wiki.php/TinyMCE3x:How-to_implement_TinyMCE_in_PHP

Facebook like button flyout appears then disappears on a page with no other content

I have added a facebook like button to my page, however when it is clicked the flyout appears, and then disappears.
At first I thought it was other elements on the page hiding it, but the problem persisted even on blank pages.
Tried both the iframe and html 5 codes that were generated by facebook and neither seems to work.
iframe - http://jsfiddle.net/aDK95/1/
Html 5 - http://jsfiddle.net/L9nZZ/1/
In both cases it seems to been hidden by the hidden_elem class:
#facebook .hidden_elem {
display: none !important;
}
It seems very similar to this bug reported at FB that was reported in May. However there doesn't seem to be much movement on it.
Has anyone else come across this? Know of any work arounds?
I came across this bug and it flummoxed me for quite a while. The steps I took to rectify it are as follows:
Ensure that you have put in the Javascript SDK initialization
Make sure that the #fbroot div is not inside a hidden div
In the Open Graph tags on the page, the og:url has to be set to a https protocol
and not a http protocol
Run your page through the Facebook Debugger at https://developers.facebook.com/tools/debug to check for any errors. Another interesting point which helped me resolve this was that when you put in your "URL to Like" value in the Like configurator, the dynamic like button generated shows whether that url would work well or not.

How can I hide like button or div from Firefox?

I am building a web page and I have included Facebook's Like button. Works great in all browsers but not in Firefox. When clicked in Firefox, it creates an endless loop of opening and closing a facebook login window. This is a known issue that Facebook isn't looking like it will correct anytime soon.
Can anyone tell me what code I might write to hide the like button (or a div containing the like button) from Firefox only? I've never written code to detect a browser and then have my site function a certain way. Not a javascript guru here. Thanks!
You can do this using the navigator javascript object, but it sounds like you have deeper problems if the facebook like button is causing an endless loop of window loads. You most probably have other errors in your code. The button should work fine in firefox.
Here's how to text for firefox using the navigator object,
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
// user using firefox
}
This code parses the userAgent string, the string that defines the user's browser, of the navigator object. It looks for a string of the format Firefox/x.x or Firefox x.x.
This should work for you
<div id="likeDiv">
my div
</div>
<script>
if (navigator.userAgent.indexOf("Firefox")!=-1)
{
// Remove the element from the dom
var Node1 = document.getElementById('likeDiv');
Node1.removeChild(Node1.childNodes[0]);
}
</script>
Hope this helps

How can I block until the user hits the hits "close" on FB.Connect.logout?

I have some HTML that looks like this:
<a onclick="FB.Connect.logout(function() { window.location = '/'; });">
link text
</a>
logout brings up a modal that tells the user he's logging out of Facebook and has "close" button on the bottom right. Unfortunately, the browser proceeds to '/' per the callback function. How can I stop that from happening so that the user has enough time to read what's in the dialog?
Also, the close button seems kind of useless since it gets blown away once the callback gets called, so I feel like I'm missing something there...
PS: This seems like a long shot, but I'd like the user to be able to stop the log out process if having to log out of fb changes his mind. Is there a way to do that?
Have you tried the pound sign? # This tells the browser to redirect to an in page anchor..and doesn't generally redirect anywhere. This might work for you!
If you're performing an action rather than going to a location, I'd recommend using a <button> element.
With Prototype:
<button id="button-logout" value="Logout" />
function finishLogout(isLoggedOut){
if (isLoggedOut) {
location.href = "/goodbye";
}
}
function beginLogout(){
//preparation if necessary.
FB.Connect.logout(finishLogout);
}
$('button-logout').observe('click', beginLogout);
It's always better to have your events in the javascript rather than inside your tag's onclick. And, although I did make two seperate functions, it's easier to revise and reuse them later, and you can always minify them if you're looking to optimize.