Question

Related but dormant: Javascript to open URL within a new Tab and a number of others...

I have a client who insists that a particular link needs to open in a new tab, rather than a window. It's being generated by the "onclick" event of a form submission button, called by a jquery function in the php document that looks like this:

function newTabLink($element,$url) {        

    ?><script language="JavaScript" type="text/javascript">//<![CDATA[
        jQuery(document).ready( function() {
            jQuery('<?php echo $element; ?>').click( function() {
                window.open( "<?php echo $url; ?>",'_blank' );
                } );
            } );
            //]]></script><?php     
}

I also have a css declaration in my stylesheet which tries to force new windows into tabs rather than new windows:

* { target-new: tab !important; }

The css target-new property seems to work in IE9, forcing the popup into a tab. FF and Chrome/Safari both default to tabbed browsing, even without that property set. But how can I force IE8 and 7 to open this particular link in a tab?

Any ideas?

Was it helpful?

Solution

You cannot reliably do that. As you note, Firefox and the WebKit browsers can be configured to open new windows however the user wants. I hope that IE9 can be configured to override the behavior of that "style". (edit — that appears to be a draft CSS3 thing - I hope personally that it dies in committee.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top