I'm theming my Wordpress and want to show just number of likes in a fan page. How can I show this
https://api.facebook.com/method/fql.query?format=json&query=select+fan_count+from+page+where+page_id=160397290640478
in my theme? I can't use fopen() function. Maybe javascript? How?
Sorry for this question, but I'm not a programmer.
Sorry, but after all, I got my own answer:
http://pastebin.com/desK1b6D
Thanks!
For reference, when pastebin doesn't work anymore, here's the solution to the problem:
<script>
function showCount(count){
if(count)
document.getElementById('fb_fan_count').innerHTML = count[0].fan_count;
}
</script>
<p id="fb_fan_count"></p>
<script type="text/javascript" src="https://api.facebook.com/method/fql.query?format=json&callback=showCount&query=select+fan_count+from+page+where+page_id%3D16039729064048"></script>
Related
I'm making my first steps in coding using online training. For some reasons the code for MP3 player provided in training does not work.
I wrote same code in Brackets and it does not fly. It shows buttons, but when I press them nothing is happening.
Can please someone help me what is the reason for that? Both mp3 file and html file are placed on desktop.
<html>
<head>
<title>Video Player</title>
<script>
var player;
window.onload=function()
{
player = document.getElementById("sound");
document.getElementById("btnPlay").addEventListener("click", playMusic, false);
document.getElementById("btnPause").addEventListener("click", pauseMusic, false);
document.getElementById("btnStop").addEventListener("click", stopMusic,false);
}
function playMusic()
{
player.play();
}
function pauseMusic()
{
player.pause();
}
function stopMusic()
{
player.pause();
player/currentTime=0;
}
</script>
</head>
<body>
<audio id="sound">
<source src="mlynarz.mp3" />
</audio>
<button id="btnPlay">Play</button>
<button id="btnPause">Pause</button>
<button id="btnStop">Stop</button>
</body>
</html>
If you open the developer console of your browser, in the Console tab you can see there is error Uncaught SyntaxError: Invalid left-hand side in assignment it seems you have a typo in your code player/currentTime=0; it should be player.currentTime=0;.
It will solve the problem. always be careful with the typos.
Thanks a lot for that one!. It worked. How come Brackets (dev tool I'm using) has not shown that as mistake? Also dev tool in chrome has not pointed mistake here.
I have a problem. Is there a way to change every a href, which has class "primary-action" with "#", and also give it onclick="alert('myalert message');" ?
It can be jQuery or Javascript.
I am realy desperate here. I don't have time to learn javascript for this one thing right now, and realy need help.
Thank you to anyone who can help, or atleast try.
Here is the permanent solution for multiple URLs:
Suppose You have three <a> tags in one page:
test
test
test
Your JQuery Code:
<script type="text/javascript">
$(document).ready(function(){
$('.primary-action').click(function(){
return false;
});
});
</script>
How can I access the text "All changes saved" in the dynamically created Ember script below? I use Protractor to create functional test.
<div class="is-muted">
<script id="metamorph-191-start" type="text/x-placeholder"></script>
<script id="metamorph-191-start" type="text/x-placeholder"></script>
All changes saved
<script id="metamorph-191-end" type="text/x-placeholder"></script>
</div>
Thank you in advance for your help!
I ran into a similar issue earlier and solved it in a rather unelegant manner but it does the job, try the following:
//$$('#metamorph-191-start') will select all the elements on your page with ID metamorph-191-start
//.get(1) will get the second element that passes this requirement aka the script with your text 'all changes saved' in it.
//the .getText().then(function(foo)... gets the text from the element and resolves the promise around it.
$$('#metamorph-191-start').get(1).getText().then(function(foo){
console.log(foo);
});
I said this was unelegant since it is quite the bad practice to use the same ID more than once on a single HTML page.
I am trying content dropdown from Foundation 5: http://foundation.zurb.com/docs/components/dropdown.html, but it does not work as you can see on this fiddle: http://jsfiddle.net/AQGd9/2/. Basically, the content does not appear upon clicking the link when it should.
Has Content Dropdown
<ul id="drop2" class="f-dropdown content" data-dropdown-content>
<li>This is a link</li>
<li>This is another</li>
<li>Yet another</li>
</ul>
Thanks
You need to explicitly initialize foundation with this piece of code before the end of your body, like this:
<body>
...
<script>
$(document).foundation();
</script>
</body>
I have the same problem right now. The doc says that you need include the javascript required files, there are two ways to do it:
1) All Js (core + plugins): foundation.min.js
2) Only the core, and add the plugins on demand: foundation.js + foundation.dropdown.js (in this case).
So, launch foundation Js:
$(document).foundation();
Source: Foundation 5 Js Doc
This work for me.
I am using the twitter style endless pagination for one of my projects. the problem is that my ajax logic works just fine for my first 10 posts (so the first page) but when I go down and Endless Pagination loads more posts, my ajax stops working for them. I am not sure my.
Thats how I've been stacking my js
<script src="/site_media/endless_pagination/endless.js" type="text/javascript" charset="utf-8"></script>
<script src="/site_media/endless_pagination/endless_on_scroll.js" type="text/javascript" charset="utf-8"></script>
<script src="/site_media/bootstrap/js/bootstrap.min.js"></script>
<script src="http:/site_media/bootstrap/js/bootstrap-collapse.js"></script>
<script src="site_media/bootstrap/js/bootstrap-tooltip.js"></script>
so for example tooltip works just fine for my first 10 posts, but then when pagination loads the next posts, tooltip doesn't seem to work for them.
I finally figured out what the problem was, I was suposed to use .live(). This Attaches an event handler for all elements which match the current selector, now and in the future. So when new posts load, my jQuery logic applies to them as well.