View Full Version : targetting a particular window
swallow
09-09-2002, 04:10 PM
I have decided to start sending a newsletter in order to get some traffic onto my club website. I want links to be targeted to a new window. OK so I use target ="_blank". However, I do not want 10 new windows if there are two links on my newsletter. I want the second link which the user clicks to open in the same window that was opened on clicking teh first link.
Is there a Javascript method of doing this?
beetle
09-09-2002, 04:19 PM
Well, yes and no. There's a way, but it's not Javascript, just good ol' HTML. Just use any window name that isn't a reserved word. Instead of target="_blank" try target="newsletter" or target="mywin".
swallow
09-09-2002, 04:21 PM
I C. Do I need to call the window by a name when I create it?
ConfusedOfLife
09-09-2002, 04:24 PM
Try this:
<script>
flag = false;
function doit(Name)
{
if ( flag == false )
{
oWin = window.open("Name.html","something","");
flag = true;
}
else
{
oWin.location = Name + ".html";
oWin.focus();
}
}
</script>
</head>
<body>
<a href="javascript:doit(1)">1</a><br>
<a href="javascript:doit(2)">2</a><br>
<a href="javascript:doit(3)">3</a><br>
<a href="javascript:doit(4)">4</a><br>
<a href="javascript:doit(5)">5</a><br>
<a href="javascript:doit(6)">6</a><br>
</body>
Edit : I didn't see beetle's answer, of course it's better and easier, but your window wouldn't be focused on when you try to open the second, third and ... links.
swallow
09-09-2002, 04:29 PM
Thanks. I take it teh script goes in the head of my newsletter.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.