views:

55

answers:

2

I have this situation:

There are a login page with a login form (form action is $_SERVER['PHP_SELF']). When user login, it will check what application the user can access and open all the application that available for that user in new tab. If user can access application (for example) 'Docs' and 'Sites', it will open 2 tabs.

I Open new tab using window.open('app1.html','_newhtml');, some people say that it only works in Firefox. It's OK, no big deal for me.

The problem is, It only open 1 tab, although I write it 2 times

window.open('app1.html','_newhtml');
window.open('app2.html','_newhtml');

How can I open 2 tabs? are there any hacks from server side or client side programming?

+2  A: 

The problem is, you are identifying the window with the same identifier. You are using a custom one here, but you could also provide the browser reserved ones (_self, _top and _blank)

Try this

window.open('app1.html','_newhtml');
window.open('app2.html','_newhtml2');

or just use _blank which won't guarantee a new tab, merely a new window if the browser supports it.

alex
Thx for the answer alex, this is working
Permana
+1  A: 

Using '_blank' as the target will always open in a new browser view. This may be a new tab or a new window, depending on the user's browser and settings (some browsers don't support tabs, et cetera).

The other option is to use two separate named identifiers (such as '_newhtml' and '_newhtml2'), which would then allow you to open other pages in those same 2 windows later.

Amber
i don't exactly know what is the second parameter. Thanks for the answers
Permana