Facebook share in a website (get value from textbox) - javascript

I am in a process of building my very first website and I came into some problems when trying to implement Facebook Share into my site.
What I am trying to accomplish is:
1) Get URL from textbox in my site.
2) Share it on Facebook.
This is the code I tried:
<center>Share in Facebook
It works with:
<center>Share in Facebook
But I need it to work with dynamic textbox text. For same URL, it works fine.
But it doesn't work with my first code example and I get this error message on Facebook Share popup:
href should represent a valid URL
This is image of the error:
Thanks, I hope I will find help here.

Related

Using href in Javascript with webpages like google

This is gonna sound like a dumb question or maybe it is a dumb question and I apologise in advance, but I am having a problem trying to get my window.location.href to show an alert on webpages like google and youtube.
It shows alerts on the live server fine, however its just that I can't tell if its working on webpages like google and youtube as I am not seeing any alerts. When I do run it, I do see it re opening the tab I just minimised, so it maybe working, but is there any other form of validation too see if it is working.
I'm still pretty new to JavaScript but this is the code I'm using, any advice would be much appreciated. Thank you again
<p id="URLc"></p>
<script>
document.getElementById("URLc").innerHTML =location.href
alert('This website is'+ window.location.href);
</script>
I see that your question isn't clear enough.
However, if you want to navigate to another web page from yours and display an alert there. You can not display alerts in web-pages which you don't owe because the page you open will have a separate script and your JavaScript code won't affect it.
You can display the alert before changing the location.href.
You can use postMessage() as illustrated here.
You can display a pop-up window with the message you want to display, by making another HTML file, adding the message you want to it, and doing like this:
window.open( {{THE HTML FILE URL}} , 'popup', 'width=600,height=600');
window.location.href = {{THE URL YOU WANNA NAVIGATE TO}};
Not That you're able to pass the URL you want to navigate to to your HTML file using Query Strings
If your question is about displaying your location.href on your website, it should just work fine. I opened https://www.youtube.com/?feature=ytca, opened the browser console and ran alert(window.location.href); and the alert got displayed.
If you don't mean this, please make your question more clear.

Make Google Bot detect AJAX contents

I'm developing a site (not mine) and I encountered a big trouble!
In this website I've got some modals that will open after a user clicks on a product, but I need to do so Google Bot detects these modals like pages. When a modal opens, a JS Function adds a # parameter to the URL like "#abc=modal_one".
I want that in Google Result appears this page as "www.test.com/page.php?#abc=modal_one". I've tried (and I'm trying) to render the page like Google Bot in Google Search Console, but GSC opens only the page and not the modal. I also added a ES6 (JS) code that just edits the page title when the modal is showing to the user (after user clicks to open the modal) but nothing, Google does not detect the page title set after the page is loaded.
If you can't understand something just tell me and I will try to explain my trouble newly.
Thanks in advance to all the StackOverflow community :)
Try exporting the various pages to a dynamic sitemap that Google can read.
View the Categorize parameters with the URL Parameters tool page for more information.

Simple Facebook "Share Link"

I am working on a site where posts are made and I'd like to give visitors the ability to "share" a particular post that they link on their timeline. I have never done any social media integration, but I followed the instructions via the FB API and am still having problems. It's easier to show you than try to explain it. Go to http://www.badcustomerbureau.com/ and click on any of the Share links at the top of any post. Instead of sharing the post you clicked on, it tries to share a generic post with the same photo every time (photo of a dog). I used the code generator on the FB help site and it still has this issue. Please help!
I did receive one suggestion from a member of this site, but I am still seeing the same behavior.
I think its already working. I've tried it before in my own website http://socialviralworld.com/. You just have to login first and see the changes.
See image:

Imacros Creat facebook fanpages

I recorded an imacros script to creat a new facebook fanpage, but when i replay script, it aways showed: RuntimeError: element was not found. (Google search said: facebook random tags ID, buy Xpath also faild)
does anyone can help?
I have macros for creating and using fan pages automatically.
I have to update them every month or so because facebook changes the tags a lot!
1)Some tags change from refresh to refresh but its always one of 2-3 options so once you get them down its not that bad.
2) use experimental recording , it does a better job for some facebook elements
3) if you cant seem to work out the id tags use X/Y position for the problematic button.
4) The real problem with facebook comes later after you got the automation working. They stop loading random buttons and pages that they see you using with the automation and it is hard to overcome.

Facebook share with custom text on button

It used to be done this way:
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
<a type="button_count" share_url="http://google.pl" name="fb_share">Share this page on Your's wall</a>
And it used to generate a share button with text "Share this page on Your's wall" instead normal "Share". Since last update it doesnt work anymore.
Is there any posibillity to change the text on share button?
With Facebook JS SDK:
You now have to use the Feed Dialog, which is part of the Facebook JavaScript SDK.
Without Facebook JS SDK:
If you don't want to be bothered with their SDK, you can use this simple link instead:
Share this page on your wall
Here's what it'll look like if you're sharing Google.com with this link:
https://www.facebook.com/dialog/feed?app_id=140586622674265&link=http%3A%2F%2Fgoogle.com&name=Google&redirect_uri=http%3A%2F%2Fs7.addthis.com%2Fstatic%2Fpostshare%2Fc00.html
Also, please acknowledge these three things:
You need to replace [[URL]] and [[TITLE]] with a link to the page you want to share and its title (both url-encoded).
The Feed Dialog has to show from which Facebook app the post comes from. The app_id parameter in the URL above is the one from AddThis. Create a Facebook app and put its own id in the URL to use the name you want instead of "AddThis Sharing". You can keep the app_id from AddThis though, it works just fine.
The last parameter (redirect_uri) is the page where the user will be redirected after sharing. It's currently a page from AddThis with some JavaScript that will close the tab / window. That way, the dialog just disappears when it's not needed anymore. You don't have to change it either, works great.

Categories

Resources