Welcome to WebmasterWorld Guest from 54.226.62.26

Forum Moderators: incrediBILL

Message Too Old, No Replies

Forcing new tab (not window) using javascript?

How to do this correct..?

     

brandmaker

4:11 am on Jan 20, 2010 (gmt 0)

5+ Year Member



I would like to force all browsers to open a link in a new tab, not a new window.

Right now I'm using:

<script type="text/javascript">
function show(id, url)
{
new_win = window.open(url,'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
}
</script>

<a href="somesite.com" target="_blank" onclick="show('{$dfsfds.ID}','/outbound/{$something.ID}/'); return false;">

This is not working in Mozilla or IE. Is there an alternative to "new_win = window.open()"?

Edit:
[w3.org...]
They mention this here: * { target-new: tab ! important }
Could this do the job?

[edited by: brandmaker at 4:16 am (utc) on Jan. 20, 2010]

tedster

4:15 am on Jan 20, 2010 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



1. I never found a way to do this.

2. Not every browser user even wants to use tabs, or would understand a new tab if it opened. It's almost always better to let the user control this kind of behavior on their side.

brandmaker

4:24 am on Jan 20, 2010 (gmt 0)

5+ Year Member



Thanks for the reply, tedster.

I know, but with the code above Mozilla is actually opening a new window. Normally it opens a new tab (on target="_blank" links).

And another question: If a user has entered www.amazon.com in one window. Then he opens a new TAB and clicks on my affiliate link. (My affiliate link is opened in a new WINDOW.) Will the cookie get stuffed correctly so the sale is registered?

Second alternative. If he has www.amazon.com in one window, then opens a new WINDOW and clicks on my affiliate link - will the sale get registered?

Assuming the tracking method is cookies, not IP.

penders

10:11 am on Jan 20, 2010 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



...the code above Mozilla is actually opening a new window. Normally it opens a new tab (on target="_blank" links).

I'm not too sure why the difference between JavaScript and HTML (TARGET="_blank") popups in Firefox (or Opera and Chrome for that matter, which appear to behave the same). JavaScript opens a new window; TARGET attrib alone opens a new tab. This appears to be the default behaviour. IE8 and Safari open a new window in both cases (at least by default).

However, the browsers (apart from Chrome and Safari as far as I can see) do have a user preference as regards to Windows OR Tabs.

In Firefox (3.5), Tools > Options > Tabs > "Open new windows in a new tab instead". Appears to be checked by default - but this does not influence JS popups.

Opera (10.10) has an opposite preference, Tools > Preferences > Advanced > Tabs > [Additional tab options...] > "Open windows instead of tabs". Which is NOT checked, but again does not appear to influence JS popups.

IE8's preference, however, does influence both JS and HTML popups. Tools > Internet Options > General > Tabs [Settings] > "Always open pop-ups in a new window" (selected by default) OR "Always open pop-ups in a new tab". HOWEVER, IE8 does have the additional option, "Let Internet Explorer decide how pop-ups should open" - in which case it behaves the same as FF, Opera and Chrome - JS new window, HTML new tab!

TBH, as long as the browser has a user preference as regards Windows/Tabs, I don't think the software should be able to override this. Although I think the software should be able to indicate a preference, which the user/browser can choose to ignore.

brandmaker

11:43 am on Jan 20, 2010 (gmt 0)

5+ Year Member



Ah, I see! Thanks for that information. That was very useful.

I removed _blank from the "new_win = window.open()" statement - to just have a normal target="_blank" in the link - now Mozilla opens a new tab.

Now it's up to the IE users. :)

Any thoughts about the two cases I described earlier?

- Will the cookie get stuffed so the sale will be registered if IE opens the affiliate link in a new window (that the user just closes right away)?

penders

1:36 pm on Jan 20, 2010 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



And another question: If a user has entered www.amazon.com in one window. Then he opens a new TAB and clicks on my affiliate link. (My affiliate link is opened in a new WINDOW.) Will the cookie get stuffed correctly so the sale is registered?

Second alternative. If he has www.amazon.com in one window, then opens a new WINDOW and clicks on my affiliate link - will the sale get registered?

This is just my opinion, any comments appreciated...

AFAIK there is no difference between tabs and windows in this respect.

I believe Amazon's affiliates are triggered with a "tag=" in the querystring of the URL. Not sure if this explicitly sets a cookie itself, or whether it becomes part of the session, but either way if the user goes back to their original Amazon Window/Tab, after having clicked on your affiliate link, and refreshes/navigates to other pages, then they should pick up your affiliate 'tag' - I would have thought. If, however, they are already part way through the payment process in the other window, then I'm really not sure.

...the affiliate link in a new window (that the user just closes right away)?

Will the session be terminated? I'm not sure.

May be the Amazon discussion boards can better help with this one?

brandmaker

1:55 pm on Jan 20, 2010 (gmt 0)

5+ Year Member



I was actually thinking about affiliate links and cookies in general. I should've said I just used amazon.com as an example. But I see your point. It makes sense.

I guess I can talk to one of the affiliate networks I use. If they know for sure I can come back and post their answer.

Anyway, thanks for the help. 35% of my visitors (Mozilla users) will be happy now. :)

penders

2:52 pm on Jan 20, 2010 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Or may be the Advertising Sales and Affiliate Programs [webmasterworld.com] forum?
 

Featured Threads

Hot Threads This Week

Hot Threads This Month