Jump to content

Opening a new window rather than tab


Recommended Posts

Using target="_blank" in <a>..</a> nominally opens a new window. In browsers with a tab facility however it usually opens a new tab. You can usually pick up a tab and move outside the browser window to create a completely new window, but how do you force a completely new window rather than just a new tab f romthe start?

 

I haven't come up with search criteria that give me anything other than target="_blank".

 

Thanks

Link to post
Share on other sites

You can't do it with HTML. It's up to the user to decide how they want their links to behave, most browsers have an option for the users to choose how they want new windows to appear.

Link to post
Share on other sites

Javascript usually will create a new window when you set width and height parameters in the window.open() method. Are you sure your users would prefer your website to open a new window rather than a tab? You must try to make your website easy to use.

Link to post
Share on other sites

Yes, easy of use is the problem. For the post 60 generation, with which I am dealing, when information disappears there is a tendency to think that it is not available rather than not visible. The current modes of operation used on the web are not obvious to a lot of older people and as soon as they manage to learn some they have a habit of changing.

Currently they click on a link to create a working page, which has to run on a different server, and loads in a new tab. When wanting to return to the original page, they seem to use the tab OK, but when trying to get back to the working page, they click on the link again in the original page to get back to the working area, rather than just the tab, which just sends them through a new start up loop and creates another tab. Opening a new window might make it more obvious that the two pages co-exist and also allows easier cross-reference between the data in the two pages. I could just stay in the original tab, but that creates a completely different set of usability issues. No perfect solutions.

Link to post
Share on other sites

I think this can be solved with a bit of Javascript.

You can use window.open() to create a new tab (not window) but when the user clicks the link it will focus the window instead.

var win;// Execute openTab when the link is clickedfunction openTab() {    // If there's already a window, focus it    if(win) {        win.focus();    } else {        win = window.open("document.html");    }    return false;}

If you want to get a bit more into Javascript, it would be convenient to use the event object and methods like preventDefault() to stop the link from activating when Javascript is available but I'm just putting a simple code here to show the idea.

Link to post
Share on other sites

You can do it in HTML.

 

It's using the target attribute.

 

 

For example; <a href="#" target="_blank"> does a new tab or window.

 

 

_blank Opens the linked document in a new window or tab _self Opens the linked document in the same frame as it was clicked (this is default) _parent Opens the linked document in the parent frame _top Opens the linked document in the full body of the window framename Opens the linked document in a named frame

 

 

Source; http://www.w3schools.com/tags/att_a_target.asp

Link to post
Share on other sites

You can do it in HTML.

 

It's using the target attribute.

 

 

For example; <a href="#" target="_blank"> does a new tab or window.

 

 

_blank Opens the linked document in a new window or tab _self Opens the linked document in the same frame as it was clicked (this is default) _parent Opens the linked document in the parent frame _top Opens the linked document in the full body of the window framename Opens the linked document in a named frame

 

 

Source; http://www.w3schools.com/tags/att_a_target.asp

I would recommend reading the thread more thoroughly before trying to answer.

Link to post
Share on other sites

I would recommend reading the thread more thoroughly before trying to answer.

My target="_blank" works in a new tab, but I don't see why you need a new window.

 

If I'm honest.

Link to post
Share on other sites

Haven't tried your latest suggestion with the JavaScript, but did try a simple window.open. Nothing happened. So went back to the simple 'try it' examples in W3Schools and substituted my link - all OK. The difference to the W3S example is that I am trying to activate the link from a list item in a drop down menu and the W3S example is via a button.

So either this is not possible or my construct is way off, First tried,

 

<li><a onclick="NewWindow()">Test LINK</a><li>

 

having just substituted the onclick for the original href and having put the href link into the NewWindon function. No result.

Then tried the onclick within the <li>, taking out the <a></a>. No result.

Then tried, out of interest, putting a button in place of the <a></a> construct. No result.

The only affect of the last two was to muck up the formatting of the menu for that item.

So then tried putting the original href back and adding the onclick within the <a></a> and then the <li>. No result.

So if it is possible to get an onclick event into a menu item structured with a series of unordered lists, what's the syntax?

 

Thanks.

Link to post
Share on other sites

Thanks for everyone's suggestions, but I'm giving up on this for the present. I've tried numerous variations in my code and nothing seems to work. When I have cut and pasted my very basic code into the W3schools 'try it' pages (which I used as the basis in the first place), sometimes it works and sometimes it doesn't. It would have been nice if it worked, but plenty of other things to do.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...