woraphol.j
woraphol.j

Reputation: 1321

Twitter way of handling links: click then AJAX, open a new tab then full load

This question is in fact more about html+Javascript but Twitter is cited because I see a working example on it.

In Twitter, the link to a user profile is displayed like @Yourname. If you click on it , an AJAX request will be made for the user profile and then the current page will be filled with that user profile without reloading. But when you right-click on it and select 'open in new tab' it will work just like a simple link that opens a new tab and a full page load will be done in that tab.

I think it has something to do with Javascript but not sure how to do it. Please help enlighten me.

Upvotes: 0

Views: 312

Answers (1)

ScottR
ScottR

Reputation: 3120

The link has an event handler on it that cancels the default action when clicking (load the href attribute on the page), and loads the profile on the right.

When you right click in your browser on the link to open in a new tab, it doesn't cancel the default action, and goes to twitter.com/#!/profilename.

Upvotes: 2

Related Questions