Opening Window With Target

R

Robert Atkinson

Does anyone know how to replace <a href="url" target="_blank"> with
window.open, keeping the window settings the same, i.e. same size, same
toolbars, etc.

I've tried document.open, and window.target, but nothing I do seems to
open in a new window.

Cheers, Rob.
 
M

Michael Schmitt

Hi Rob,

Robert said:
Does anyone know how to replace <a href="url" target="_blank"> with
window.open, keeping the window settings the same, i.e. same size, same
toolbars, etc.
if you use
<a href="http://www.google.com" onclick="window.open('http://www.google.com','');return (false)";>open win</a>
the window will be opened with default size by the onclick handler function. This will also work if the user has
JS disabled, because the href is still there. Of cause you can use this with any event handler.

cu, Michael
 
S

Simon Wigzell

<a href="url" onclick="SomeName=window.open('','SomeName','')"
target="SomeName">


I think. Those are pairs of empty single quotes within the widow open
statement, not souble quotes.
 
G

Grant Wagner

Robert said:
Does anyone know how to replace <a href="url" target="_blank"> with
window.open, keeping the window settings the same, i.e. same size, same
toolbars, etc.

I've tried document.open, and window.target, but nothing I do seems to
open in a new window.

Cheers, Rob.

You can't do this. There is no way to determine the size of the current
browser window in a cross-browser compatible way. You also can't reliably
detect the current chrome (what menus, toolbars and statusbars might be
showing).

<a href="url" target="_blank"> usually opens a new window with the default
size, position (although windows will shift the window down and to the
right approximately 20 pixels so you can see the titlebar of the original
window) and with the default chrome.

You can attempt to control the chrome using window.open(), but there is no
guarantee you will open a new window, let alone control the chrome that
window has (any new window that a Web site attempts to open gets opened in
a new tab for me in Firefox, so any of your attempts to control the size,
position or chrome of a new window fail).

In the future, check the documentation, rather then trying things at random
hoping it will work. Computer programming (which is what "Javascripting"
is) requires very specific syntax to work correctly.

Information about window.open()

<url:
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202731
/>
<url:
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp
/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top