SQR
March 4, 2004 1:09 PM   Subscribe

I'm trying to code a list of links to all open in the same new browser window. Since every link in the document should open in the same window, I'm using the {base} tag, for the sake of simplicity and size, but I've also tried adding "target='random_name'" to every single link on the page. Nothing's working. All the links are opening in new windows. Help?
posted by grrarrgh00 to Computers & Internet (10 answers total)
 
Here's an explanation of how to do it with simple javascript:

Working with Windows

You can't just put target="something". There are pre-defined values for that attribute, none of which are going to do what you want them to do for this task.
posted by fletchmuy at 1:38 PM on March 4, 2004


actually, you can use target in that way.

there are pre-defined values for the target attribute (such as _blank, _parent, etc), but using anything other than one of those will open a new window, with your value as the name of the window. ie...

<a href="foo" target="newWindow">

... opens a new window named "NewWindow". (note that the 'name' of the window has nothing to do with the 'title' of the window.)

these two links...

<a href="foo" target="reuseThis">
<a href="bar" target="reuseThis">

... will open in the same window. there is a uability problem with this, in that if, while returning to the parent window to click the second link, the child becomes obscured behind another window, reloading its contents will not pull it forward, ie, it will still be obscured. this can be overcome by using javascript to pull focus to the loading file.

btw: using the _blank value should *always* open a new window.

btw2: if you need to control toolbars, size of window, etc, you need to do that with javascript, but really only once. any subsequent links that target the same window name will open in the same window.
posted by o2b at 2:01 PM on March 4, 2004


i didn't actually say this: the fact that you are using random targets is why they all open in different windows. using identical targets is what you want to do.

BTW, again: the target attribute is invalid if you are using XHTML strict. Your options are to use XHTML transitional, or use all javascript.
posted by o2b at 2:06 PM on March 4, 2004


Damn, you learn something new every day. And I call myself a web developer. For shame...
posted by fletchmuy at 2:13 PM on March 4, 2004


I should have specified that I think I'd rather use html and have several new windows open than use javascript and risk crashing someone's browser.

o2b, i've been using

{a href="foo" target="somewordthat'snot_blank"}
{a href="bar" target="somewordthat'snot_blank"}

and yet it continues to open the two documents in different new windows.
posted by grrarrgh00 at 2:13 PM on March 4, 2004


And I'm using straight HTML, no XHTML at all.
posted by grrarrgh00 at 2:15 PM on March 4, 2004


a quick test of the method worked for me in IE and Mozilla; the TARGETs may be conflicting with your BASE tag (or some setting in your browser... which browser are you using?). Can I see your HTML?
posted by o2b at 2:23 PM on March 4, 2004


Could I e-mail it to you?
posted by grrarrgh00 at 2:31 PM on March 4, 2004


to prevent broadcasting my email addy to spammers, use this form:

http://o2b.net/contact/
posted by o2b at 3:10 PM on March 4, 2004


o2b is correct. Essentially, what you put in quotes after target becomes the name of that window and any other targets that have the same name will load in the same window as long as that window is still open. I've done it a zillion times, give or take.
posted by dobbs at 3:16 PM on March 4, 2004


« Older Hawkman Car Decal   |   Need App to Automatically Archive Several Hundred... Newer »
This thread is closed to new comments.