Link anchors working only once in iPhone's browser - iphone

I'm making a mobile interface for my web app, and I'm trying to use anchor links to make navigation easier. My code is similar to this:
Jump to section 2
... lots of stuff here ...
<h2 id="section2">Section 2</h2>
The problem is that the link works only once. So if a user, using his iPhone, taps that link and jumps to section 2, then scrolls back to the top and clicks that link again it won't work. He has to refresh the page.
Is there any way to get around this?
Appreciate your help

Don't use id, use <a name="section2">Section 2</a>

Related

Why doesn't RouterLink take you to the top of the new page but a regular HTML link does when both compile to the same HTML?

I have <router-outlet [routes]="Routes.all"></router-outlet> set in my app component. I have a page with links at the bottom of the page. If a user clicks a link I want them to be taken to the top of the new page.
If I use RouterLink the current scroll position is retained so the user lands in the middle of the new page.
<a [routerLink]="RoutePaths.featurePage.toUrl()">...</a>
If I use a regular HTML link, I get the behavior I want, the user lands at the top of the new page.
...
What I really don't get is how they can respond differently yet compile to the exact same HTML code.
<a class="_ngcontent-zbb-0" href="/feature-page">...</a>
What am I missing here?
I understand regular non-Dart Angular has something called scrollPositionRestoration but it doesn't seem to exist for AngularDart.
The answer is really a hack to return the scroll position by utilizing the
window.scrollTo(x,y) function.
This issue was raised in here in regular angular
Equivalent to autoscroll=true: automatic scroll to top when route changes
remmeber to import dart:html

Facebook Like + Send (send not showing)

So I'm using Facebook Like combined with the send button using the following HTML5 code:
<div class="fb-like" data-send="true" data-layout="button_count" data-width="120" data-show-faces="false" data-colorscheme="dark" data-font="arial">
The problem is that the "Send" button flickers for a moment and then disappears. Note, this is only the case with data-layout=button_count. When data-layout is set to 'standard', it stays, although shows other undesirable text (in our case).
Nowhere in the documentation that I can find does it say that the data-send=true flag does not render the "send" button when data-layout is set to to "button_count".
This is the case even on the facebook example page:
https://developers.facebook.com/docs/reference/plugins/like/
The fact that the send button flickers and then disappears (EVEN ON THE FACEBOOK EXAMPLE PAGE), leads me to believe this as an error.
Can someone in the know shed some light about what is going on?
Thanks!
It seems like the Send Button is having some issues currently as you can see by searching in the bug reports system.
These two tell me that something is wrong: Send button opens new tab and Problem with Like/Send button with data-layout set to 'button_count'.
I'm not sure that what you're describing is related, but it's not far fetched.

How to trigger Facebook like button from custom button?

I have created a custom Facebook like button.
How do make it that when I click the button, it will trigger the like button provided by Facebook like the one below?
According to facebook policy on Social Plugins point 4 states:
"Don’t obscure or cover elements of social plugins."
You can't change the image directly because it's provided by Facebook.
The Facebook button is in an iFrame with a source that is on a different domain, Facebook’s domain, and so you can't change the button as it's protected by the same-origin policy.
Also, Facebook’s policy prohibits changing their buttons and logos when using embedded content from Facebook, like social buttons.
So, you're not suppose to be able to change the FB buttons, and even if you could it would be against the Facebook Terms of Service.
But... if you still want to do it, you can use the native Facebook button and lay your own image on top or below the Facebook button to fake a custom button.
Laying your image on top is only possible if you use CSS3 pointer-events, wich will make your image click-through and the click event will work "through" your image and actually click the Facebook button.
This only works in newer browsers that support Pointer Events.
Another option is to lay the image behind the FB button and set the FB button's opacity to zero.
I have used this several times myself, and with a little digging around in the Facebook code you can attach hover events and everything else to make it look like a custom button. You would have to find what elements to set opacity : 0 on.
Have never spent any time trying to figure out how to make the unlike function of the original button work on a custom button, but it's probably possible.
All my attempts to actually trigger the FB button with javascript or jQuery trigger() have failed, but maybe someone else has figured out how to do it?
When you create a html element with fb-like class, facebook javascript SDK convert it with a like button when document loaded. You can make a custom element and trigger click event of like button when user click your custom button.
For example :
<input type="button" id="mycustombutton" value="Like">
<div style="display:none" class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>
jQuery code:
$("#mycustombutton").click(function(){
$(".fb-like").find("a.connect_widget_like_button").click();
// You can look elements in facebook like button with firebug or developer tools.
});
Update
Facebook SDK has been creating like button in an iframe and browsers not allowing to intervention to the iframe in the page. I think add event listener to element in iframe does not possible anymore.
This is not allowed for the obvious reason that it would lead to fraud. Imagine if each time you clicked an image on the web you don't know if it's an actual image or if it will result in a like and show up in your FB feed. It would be disastrous.
If you do want to do this legitimately, you will need to create an app and have the user authorise the app when he visits your site. This will open a popup where the user agreed to let the app access his FB account. Once that is done you can then send the like request on behalf of the user via a server-side script. In other words, it's not worth the effort.
If on the other hand you just want to get the like count for a page and display it however you want, you can do so via a request to "http://graph.facebook.com/#{url}" which will return a JSON payload with the number of likes. In jQuery it would be:
$.getJSON("http://graph.facebook.com/#{url}", function(data) { alert(data.shares); });
I think that facebook goes through great lengths to make sure people can't trigger the "Like" button. This is to prevent scripts from automatically clicking the "Like" button when someone visits the site.
You may be able to override the style of it using CSS and have your image show instead.
You can overlay your button on top of the Facebook like button and use css to hide the Facebook button.
Not sure on the legalities of this however.
You could try to trigger an Ajax request like this
FB.api(
'me/og.likes',
'post',
{
object: "http://samples.ogp.me/226075010839791"
},
function(response) {
// handle the response
}
);
https://developers.facebook.com/docs/reference/opengraph/action-type/og.likes
http://sharingbuttons.io/ allows to make social media share buttons with no javascript at all (Not a like button like in the question…). For Facebook, it just uses a link like this:
<a href="https://facebook.com/sharer/sharer.php?u=http%3A%2F%2Fsharingbuttons.io"
target="_blank" aria-label="Share on Facebook">Share on Facebook </a><br>Here on Stackoverflow, you have to cmd + click to open the link in a new window.
Customize it with your own CSS and, to mimic the share button, just open the url in a popup instead of a target="_blank".

adding facebook like and tweet buttons to an exhisting tumblr theme

I am trying to add facebook 'like' buttons and tweet buttons at the end of each blog post on my tumblr blog. I used the 'minimalist' theme on tumblr. Ive tried just about every method to insert the html properly and nothing has worked. Below it the current full HTML that I am using. If you go to my site right now there is a facebook button and it actually works but there is a ton of blank space underneath that I cant get rid of. Also, it works in Safari but not Firefox which is odd. The fbook code is right before {/block:posts}. I've been able to look at other formats of buttons but they either like my entire page rather than individual posts or I have this same spacing/firefox issue. Can anyone help?
</div>
</article>
Comments
{/block:Posts}
I cant even get that. I've done this task a few times before with other themes and it is no problem at all. It sounds like you didn't uncheck the boxes on Facebook that enable the big black space go back to f.b. and get a new code made from the link page. Do not forget to uncheck the unneeded stuff or that will also be embedded in the code given you.

JQTouch animation flicker

I have been working a JQTouch app. The functionalitly is correct however my animations on some menu items flicker, especially when you click a back link. The strange thing is it is only on certain menu items.
All pages are loaded in the same way via AJAX.
Can anyone shed any light on this?
site can be viewed at:
http://www.alliancerail.co.uk/ip/iphone.html
Thanks
Chris
I think you have an extra closing </div> that appears after "about" and right before "gnwr." Not sure if this will end up fixing your flicker problem...
You are loading content dynamically. Sometimes the jqt animates to the new page before that page has content. Try including more content in index.html such as the about or contact pages. You can also write your own ajax routines that get fired from onClick events bound to the anchor tag on your home page.
The goog group is a great resource -> https://groups.google.com/forum/#!forum/jqtouch