I'm putting up a "special offer" on my website where if users like my website via a facebook like button, then can access a special form where they can ask me to look at their website and other stuff. I can't seem to find an easy way to do this without getting into the facebook api. So basically, is there a way to reveal an element (#ask_form) when the + like part of the facebook like button is clicked? (.connect_widget_like_button clearfix, .like_button_like) Any responses would be helpful. If there's a way to do this with the FB API where if a user unlikes it it would go away and have more features that'd be cool to. I look forward to reading your responses.
You don't need jQuery for that. Have a look at the 1st and 2nd answer from this question.
$(buttonselector).on('click', function () {
$(hiddenformselector).show();
});
that's assuming the hidden form starts as display:none;
Sorry I'm not familiar with the face book api but this would cause the form to show when that button was clicked
Try it: Like 2 Unlock for Jquery
Related
I am trying to scrape the following website for a project: https://www.tunefind.com/show/chicago-fire/season-1/12210
The last step is to scrape the links to the spotify songs mentioned on a page. Normally I look into the source code and it is clear from there.
However, in this case not. Looking into the source around the spotify button I cannot find a hyperlink directing me to the song. Probably done on purpose, to prevent scraping? (Oops)
Is there a way to get the hyperlink from the button? I am aware of an 'internet' interface in Python which clicks on the buttons, but I would rather not use this, as this will affect the load time tremendiously.
Thanks!
If using Chorme, Look at DevTools, go to Network tab an reload the site. You'll find that the data yoou need is in this url:
https://www.tunefind.com/api/frontend/show/chicago-fire/season/1?fields=episodes,theme-song,music-supervisors,hot-songs,top-users,related-questions-season,composers,albums&metatags=1
not sure if that helps you, but all that data is loaded up into window.__INITIAL_STATE__
You doing it wrong by scraping the site. If they change one single thing your whole project stops working. You should use their API instead. https://www.tunefind.com/product/api
I am trying to use the code hidePreviousButton () to hide the back button in Qualtrics. Currently, I have added the back button on all questions using the Survey Options, and I would like to remove the back button on certain pages.
If there is not a way to do that, then I would be equally open to adding the back button on select pages using JavaScript as well.
Thank you for any assistance!
To hide the previous button, you can use:
this.hidePreviousButton ()
So the full code screen should look like this:
`Qualtrics.SurveyEngine.addOnload(function()
{
this.hidePreviousButton ()
});
`
I found this in the API Qualtrics page, but there it forgets to tell you that you need to include "this." before any of the commands that it gives you. At least, adding that code before the command worked for the ones I tried.
The API page for Qualtrics is actually inaccurate, unfortunately it needs a few updates. The current way to do this, is by adding:
$('.PreviousButton').hide();
to the JavaScript for any question you want to hide it for.
Right now when the user inputs a word in the textfield and hits search, the form submits using $.get(). The data(JSON) is fetched from the server and then the UI is updated.
What I want to do is pretty simple:
1) When the form submits, the URL of the browser needs to update (something like search/zyx, zyx is what the user is searching for).
2) when the page is booked into favorites, or clicked as a link from somewhere the page needs to load and then the textfield value have to be 'zyx'. Also the UI needs to show search result of zyx.
This is important to my app because I will be using Google Analytics. So the URL is needed to reflect behaviour. Plus the other issue like back button history. Is this possible using just jQuery or some extremely light libraries build on jQuery. I have searched everywhere and all the solutions I found were using MVC frameworks. Or another solution was to use a templating framework like this one. However my app is way too simple for these solutions.
So, the approach you you need is to listen to hash changes in the url and based on this get the current page and render it in a cointainer. Something like this:
Go to Page 2
<div class="page-container"></div>
<script>
$(window).on('hashchange',function(){
var page = window.location.hash;
$.get('pages/'+page+'.html', function(pageContent){
$('.page-container').html(pageContent);
})
});
</script>
Thank you every one. So I ended up using a combination between #Tulio Faria 's answer and #Gabriele Mantovani.
To get the search keyword from url I used window.location.hash
To update url used history.pushState({id: 'query'}, '', 'some_url_string');
Used $(window).on('hashchange',function(){...}) to load page of the current search keyword if either back or forward buttons of browser were clicked
If I understand you want to change the URL of the user when some actions are done. There is an other topic about it HERE, and they use
window.location.replace(url)
Hope it helps you :)
I been looking all over the internet for a code that does this, no luck so far... This is the code for my facebook like button:
<script type="text/javascript">
$(function(){
$('<iframe scrolling="no" frameborder="0" style="width: 300px; height: 80px;'+
'" src="http://www.facebook.com/widgets/like.php?href='+
encodeURIComponent(location.href)+
'"></iframe>').appendTo('#like-button')
})
</script>
I want this button to disappear after is clicked (Im thiyin to make some sort of like gate)
Cheers
First, why this is a bad idea:
Like Gates are no longer allowed, check out the changelog and the platform policy
It is annoying for the user if he can´t unlike something directly where he liked it.
Users can´t comment on the like button if you hide it right after clicking
Sometimes it needs confirmation to like something (for spam reasons, for example) - if you hide the button after clicking, the user can´t confirm and the like will not get through
It´s pointless anyway, because you will not be able to detect it for returning users so you would need to show the like button every time you refresh the page. You may use a cookie, but that´s not really a reliable solution.
...and please don´t try to solve the most simple things with jQuery. Instead of jQuery.appendTo, you can use appendChild, innerHTML, ... Learn JavaScript before using a library for it, or you will end up using it for everything - which is usually a lot slower than Vanilla JavaScript and not even less code in many cases.
That being said, it´s not that simple to hide it, you would need to use FB.Event.subscribe to subscribe to the like event: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v2.2
See this thread, for example: Attach a click() event to the FaceBook 'Like' button?
And again, because it´s very important: Like Gates are not allowed!
You can add this to your script:
$('#like-button').click(function(){
$(this).hide();
});
im a backend programmer who wants to have a window that appears in front of the current window when clicking "register".
so that you dont have to redirect to another page.
i think u guys know what i mean.
how do i do that? is it with jquery or javascript? is ajax involved?
and what is that kind of popup box called?
You want to write a div into your HTML that contains your login fields (i.e. the popup window). Set it to position:absolute; and position with CSS so it floats above the page contents and doesn't interrupt the flow when it appears. Get it all nice and positioned where you want it, then set it to display: none; so it will wait for javascript to make it appear.
Then (using jQuery), write something like this:
$('#register').click(function() {
$('#popup').show();
});
where #register is whatever gets clicked (can be most anything with id="register").
What happens whenever that form is submitted is up to you, and not any different from the options you'd have with any other HTML form. jQuery can help with AJAX if you decide to go that route and not send the surfer to another page to process the form.
It can be done using quite a few totally different approaches. As Sam said it's the concept of modal boxes.
You could do it completely on the client side using CSS and JavaScript (alternative), or via AJAX and some third-party libs.
Try being a bit more specific - what's the the backend/frontend environment? Is performance an issue (eg. minimal client-server communication)?
I believe you're referring to a modal form. You can search for modal popup javascript. There is a good javascript component called Lightbox that will help as well.
EDIT:
I mentioned Lightbox, but Lightbox Gone Wild is the one I meant. As others have pointed out, using a modal tool like this all you do is write the html you want to be displayed in the modal popup. That link is a good tutorial on the concept and explains things well.