Javascript – Window.open + href replace and pop into new window but not using target _blank

hrefjavascriptwindow

i'm stuck on something where i want the Test 1 and Test 2 links to pop-open in a new window, not target=_blank into a new window so the pop-up doesn't open as a tab in firefox, etc. The "href" in the javascript is to populate the href # in the Test 1 and Test 2 links. What am I doing wrong with this so I can also get the pop open into a new window but not as a target _blank?

<p><a id="test1" href="#">Test 1</a></p>
<p><a id="test2" href="#">Test 2</a></p>

<script> 
if(chatlink_flag == 'true')
{ 
document.getElementById('test1')window.open.href('http://www.example.com/chat1/open.htm','window1','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no'); 
document.getElementById('test2')window.open.href('http://www.example.com/chat2/open.htm','window2','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no'); 
}else{ 
document.getElementById('test1')window.open.href('http://www.example.com/chat1/closed.htm','window1','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no'); 
document.getElementById('test2')window.open.href('http://www.example.com/chat2/closed.htm','window2','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no'); 
}
</script>

Best Answer

Your code seems ok except that it is missing the "javascript:" part.

So you might try doing the window.open lines like this:

document.getElementById('test1').href = "javascript:window.open('http://www.yourpage.com/', 'window1', 'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no')";
Related Topic