#14127 closed enhancement (worksforme)
Dashboard feed widgets should open entries in new tabs
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 3.0 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
The widgets which track feeds like WP Planet, etc. and incoming links should open entries in new tabs rather than replacing the WP admin interface, or at least provide an option for this. Only internal links should open in the same tab, so that the tab remains reserved for administering the site, rather than for viewing extraneous content (not all of it relevant to the site itself).
Change History (7)
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
And here is said javascript:
jQuery(document).click(function(ev) {
var url = jQuery(ev.target).attr('href'), undefined;
if ( undefined == url )
return;
if ( 0 != url.indexOf(location.protocol + '//' + location.host) ) {
window.open(url);
return false;
}
});
scribu's right: there's no reason to make a general penalty for users so long as you have the scroll click available.
if ( undefined == url ) return;
What does that get you that if ( ! url ) doesn't?
if ( 0 != url.indexOf(location.protocol + '//' + location.host) ) {
window.open(url);
return false;
}
The problem is that in the WP admin, the internal links are not absolute, so you'll be opening them in new windows too.
What does that get you that if ( ! url ) doesn't?
You're right.
The problem is that in the WP admin, the internal links are not absolute, so you'll be opening them in new windows too.
Good observation, yet it works, because they're automatically translated into absolute URLs in JavaScript land.
I've made a little tutorial on the subject:
http://scribu.net/blog/yet-another-open-external-links-in-a-new-window-using-jquery-tutorial.html
Replying to scribu:
Good observation, yet it works, because they're automatically translated into absolute URLs in JavaScript land.
Yes and no, depending on what you're getting and the client you're doing it in.
Yes in IE--you get the full path. But in Firefox it depends:
- The href property of the target has the full path.
- But the "href" attribute has its actual value, here not absolute.
In this case
jQuery(ev.target).attr('href')
is equivalent to
ev.target.getAttribute('href') // relative path
not
ev.target.href // absolute path

What prevents you from doing Right-Click -> Open in new tab (or even scroll-press)?
If you want to enable this functionality for an unknowing client, you should install a plugin that opens _all_ external links from the admin in a new window. This can be achieved with a few lines of javascript.