sab669
sab669

Reputation: 4104

How to open a new browser window with the navigation bar enabled?

I have this JS method:

function OpenLink(strDestination)
{
    var features = ['left=10',
                    'top=10',
                    'location=0',
                    'menubar=0',
                    'resizable=0',
                    'scrollbars=1',
                    'status=0',
                    'titlebar=0',
                    'toolbar=0',
                    'width=' + (GetWinDimensions().Width - 500),
                    'height=' + (GetWinDimensions().Height - 150)];

    window.open(strDestination, "a", features.join(','));
}

Which opens a new browser window that does not have the address bar, navigation bar, or any other 'features'.

I have reviewed the MDN article pertinent to window.open. It says Internet Explorer and Firefox support the toolbar feature however it only worked in Firefox for me. The popup did not include the navigation buttons in IE, and as expected Chrome didn't either.

If I set all of these features to 1, then it was just opening a new tab. I tried changing the "a" string to "_blank" but it still opened a new tab rather than a new window.

How can I open a new window which also has the navigation bar enabled?

Upvotes: 3

Views: 2991

Answers (3)

user19328882
user19328882

Reputation: 1

You know and should know that mobile devices support new tab of different kinds and rarely windows at all if it is not available in progressive app technology like A2HS Adding event handlers to the window would solve the desktop problems with exiting . Just choose the right opening options. Thanks!

Upvotes: -1

Farzin Kanzi
Farzin Kanzi

Reputation: 3435

You can do this:

function OpenLink(strDestination)
{
   var features = ['left=10',
                'top=10',
                'location=0',
                'menubar=0',
                'resizable=0',
                'scrollbars=1',
                'status=0',
                'titlebar=0',
                'toolbar=0',
                'width=' + window.innerWidth - 500,
                'height=' + window.innerHeight - 150];

   window.open(strDestination, "a", features.join(','));
}

Upvotes: 2

Mehdi Karimi
Mehdi Karimi

Reputation: 528

This simple code open a new window with navigation enabled and with 200 width , 100 height:

function myFunction() {
     var myWindow = window.open("", "", "width=200,height=100");
}

Upvotes: 0

Related Questions