4

Question like this has been asked in SO before, and it seems it is not possible to grab the URLs opened in other tabs.

If you write blogs, then you could have seen the Preview button, which on click opens the blog post in preview mode in a new tab and each time you clicks that button the preview page which was opened previously get refreshed.

May be my question is not constructive, but I was wondering how they are capturing the tab and refreshing the page.

What kind of stuff they are using? If anybody got the knowledge, if you share it would be very helpful.

Update:

Firebugging reveals that the Preview is a button:

enter image description here

Tapas Bose
  • 28,796
  • 74
  • 215
  • 331

1 Answers1

4

Here is what Blogger uses for preview link for my post:

<a href="post-preview-auth.g?postID=12345678" target="previewpost12345678">Preview</a>

So what they do is use anchor tag with target attribute of a custom name (previewpost+postID).

When you first click on preview link, no tab will have this custom name, so new tab will be opened. If you click on it again, no new tab will be opened since the tab with that name already exist.

UPDATE:

Using button, this is probably accomplished the same way using javascript window.open(URL,name,specs,replace) method where name specifies the target attribute or the name of the window.

user850010
  • 6,311
  • 12
  • 39
  • 60
  • I think the Preview is a button not an anchor. Please see my update. Are they executing any js? like `window.open(url, name)`? – Tapas Bose May 19 '13 at 10:26
  • That's true. I was looking at "preview" link on a Posts page where posts are listed. When you go to specific page, that preview button probably uses same technique but with javascript - something like this: http://stackoverflow.com/a/13452403/850010 – user850010 May 19 '13 at 10:45