How do I override a JS URL override? - javascript

I've noticed that I've I'm logged in to FB, and someone has posted a link, when I hover over it my status bar (at the bottom...that's status, right?) shows the URL for the story, but if I right click and say "copy link" the link is transformed into one with FB tracking attached. So for instance someone posted a Boston Review story. The screen and the hover text both show that the URL is:
http://www.bostonreview.net/BR37.4/junot_diaz_paula_moya_drown_race.php
But if I actually click the link or right click and say "copy link address" or "copy link location" the URL is transformed to something like this (I swapped in some x's):
http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.bostonreview.net%2FBR37.4%2Fjunot_diaz_paula_moya_drown_race.php&h=wAQG1wXXXXXyoIDSg_ceA9JIXoBRD_o6XXXXXA0Llo4HA
I can use the element inspector to get around it, but I'm curious about whether I can disable that in other ways.
I realize this is only marginally a programming question, since I really just want to tweak my own browser behavior, but I'm not sure where else to ask.

but I'm curious about whether I can disable that in other ways.
You could write your own user JavaScript / browser extension / bookmarklet, that goes through all the links on a page, and if their href has the right format extracts the u parameter and sets it as the new href …

You can't change links on Facebook. All links on Facebook go through their link tracking page. It's probably used by Facebook in a number of ways (user tracking, anti-virus etc). All links in Faceboo, whether through an app or posted by the user manually, will have this long URL passing through l.php.

Related

How to generate a pop up without the address/title bar on clicking on a link?

I have this email campaign running which sends out a link to the subscribed users which opens up a pop up window(with the url) giving away a code which the users can use to avail discounts. The url can be copied thus generating another code which can be misused. Is there a way to generate a pop up without the address/title bar for IE,Chrome,Mozilla ?
There's no guarantee that any given browser will support it or that the implementation will be consistent across browsers.
This link indicate that the location option should control whether or not the Location/Address bar is shown. It should also have relatively good cross-browser support.
This LINK also helps you in hiding address bar.

Mobile Redirect URL with Javascript

I'm basically trying to make one link on my page and when the user clicks the link it will direct to one of these links depending on what device they are coming from.
So the link says "Download Now" and I need it to launch these URL's depending on the user agent device
If Android then android.com
If Windows then windows.microsoft.com
If Apple then apple.com
I am trying to avoid using PHP to accomplish this.
Any suggestions?
You can use the navigator.userAgent and created a method to search for android/iPhone/WindowsPhone etc string within the userAgent string. You'll need to research these online and get a list of all mobile devices and redirect based on that.
You can use the User Agent from JavaScript and intercept clicks on links, redirecting to a page depending on what User Agent is detected. Here's some code to give you an idea: Change link destination based on whether user has mac or PC. Here's a link to various User Agents which may be useful: List of User Agents
Make sure that the link still has a valid href attribute though in case the user disables JavaScript. Another possible approach is modifying all the links: changing the href attribute on page load to fit the User Agent.

Facebook 'Like' Dialog Appears and Immediately Disappears

I've been having an issue with the Facebook Like button for quite some time. I've looked all over for a solution but am quite stuck. The error occurs on my site www.MapYourVote.com. When you go to a poll page and click 'Like' the dialog appears and quickly disappears. At the same time, the counter also goes to 1 and quickly goes back to 0.
The problem is always solved for individual poll pages by using the Facebook Debug tool (http://developers.facebook.com/tools/debug). Once you use it on the url, the like button will work as expected. The issue is my website is dynamic and I can't use the Facebook Debug tool every time someone creates a new poll. The Facebook Debug tool does not reveal any problems (apart from og image size but I doubt that's the issue).
Here is an example of a page in which the Like button does not work. If you were to enter this url into the Facebook Debug tool, the Like button would work.
http://www.mapyourvote.com/Poll/Election-Result-Feelings/
Any help would be much appreciated!
I also had this problem. I was constructing a referrer url to give link-sharers a credit, so there was a different url for each user that wanted to share something. The referrer link would give the user credit and redirect to the login page of my site. With this configuration, the like dialog would appear for a moment and then disappear again, unless I went to facebook's debug tool.
What fixed the problem for me was to change from a redirect to rendering the page directly from my referral link. In fact, I changed the referral link to be a ?r=refid parameter on my root page URL. It appears to work correctly if facebook doesn't have to follow a redirect to get the og: data.
I had a similar problem and it turned out I had too restrictive cookie policy set in my browser - I only allowed Facebook to use 1st party cookies. When I allowed Facebook to use other cookies, the problem was solved. It's hard to debug when no error appears other than the immediate pop-up closeup.
I had the same problem. It was caused by url value in data-href attribute. I had there url pointing to my localhost.
When I changed the url to existing one, problem was solved.
Hope it helps
For me, the problem (Like popup disappearing after a second) was happening when the Like button URL redirected to another URL.
The fix was to add og:type, og:url, and og:title (required per https://developers.facebook.com/docs/reference/opengraph/object-type/website), then running the URL through the Facebook debugger to clear the cache (https://developers.facebook.com/tools/debug).
More at https://stackoverflow.com/a/16597060/2391566

Facebook Comments box redirects to some weird URL

Ok, I've integrated the comments box into my website, and here's is a page from my test site, where you can see the comments box on the bottom:
http://test.canp.co/programming/5/working-with-xaml
There's no problem with this. I've posted a test comment, and I can see it in my Facebook profile. When I click the link to the page from Facebook, it has appended some IDs to use it within its own system, here's the URL when I click from Facebook:
http://test.canp.co/programming/5/working-with-xaml?fb_comment_id=fbc_10150349734853770_19900263_10150349735753770#f2af0d70b1e6c8
However, when I click this link, it opens the page, scrolls to the bottom to the comment, and when the page loads fully, it redirects me to some random nonsense URL, such as http://test.canp.co/2af0d70b1e6c8. That random part changes every time, and, obviously, I'm getting a 404 error.
What could be causing this? A bug within the Facebook comments box itself, or did I do somwething wrong? What should I be doing? I want the comments box in my site.
found the following in contentpage.js on your site:
window.onload = function () {
if (location.hash.length > 2) {
location.replace("/" + location.hash.substring(2));
return;
}
Notice the #f2af0d70b1e6c8 at the end of the URL that facebook hits, and the fact that you get redirected to /2af0d70b1e6c8.....
Given that you're taking location.hash.substring(2) instead of .substring(1), I assume you're looking for #! or #/ followed by whatever resource the user wants. You should explicitly check for those exact formats instead of any old hash.

javascript jquery bookmark changing

I get the feeling that this is impossible, but is there a way to change what the url of my page will be if someone bookmarks it.
I ask because I'm running something in an Iframe, which isn't reflected in my URI. I was thinking maybe I could keep track of where the Iframe is in javascript, and then if they try to bookmark the page, I can put that JS into the URI they bookmark.
Is this possible?
You could always create clickable "bookmark this" links you could change dynamically depending on whatever logic your iframe setup uses. That won't deal with traditional bookmarks (user clicks the star in FF, adds to favorites in IE).
For anything better than this, please post a more detailed explanation of what you are doing with the iframe, and the calling page.
In short: no. Bookmark creation doesn't trigger a Javascript callback outside of rare cases like Firefox extensions.
If you want to insure that all your page content is available in a bookmarked version of the page, you'll need to add all the relevant state to the page URL. This could take the form of a session ID, encoded URL of the iframe content, or some other identifier, but it should be a unique, durable location, or else the bookmark will break eventually.

Categories