Opening New Windows/Tabs

D

d4rkn1ght

Hello!

How can I make this script I generated with HomeSite, open links in new
windows/tab instead of the same?


<script language="JavaScript" type="text/javascript">
<!--
// original code by Bill Trefzger 12/12/96
function go1(){
if
(document.selecter1.select1.options[document.selecter1.select1.selectedIndex
].value != "none") {
location =
document.selecter1.select1.options[document.selecter1.select1.selectedIndex]
..value
}
}
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
document.write('<form name="selecter1"><select name="select1" size=1>');
document.write('<option value=none>Test');
document.write('<option value=none>--------------------');
document.write('<option value="http://www.a.null">A');
document.write('<option value="http://www.b.null">B');
document.write('<option value="http://www.c.null">C');
document.write('<option value="http://www.d.null">D');
document.write('</select>');
document.write('<input type="button" value="Go" onclick="go1()">');
document.write('</form>');
// end hiding contents -->
</script>


I will like to keep this as simple as possible. I don't know anything about
JavaScript.


TIA
 
A

ASM

d4rkn1ght a écrit :
Hello!

How can I make this script I generated with HomeSite, open links in new
windows/tab instead of the same?


<script type="text/javascript">

var truc = false;

function go1(){
var S = document.selecter1.select1;
if(S && S.options[S.selectedIndex].value != "none") {
url = S.options[S.selectedIndex].value
if(!truc || truc.closed)
truc = window.open('','','width=700,height=550,resizable=1');
truc.location = url;
truc.focus();
}
}
 
D

d4rkn1ght

d4rkn1ght a écrit :
Hello!

How can I make this script I generated with HomeSite, open links in new
windows/tab instead of the same?


<script type="text/javascript">

var truc = false;

function go1(){
var S = document.selecter1.select1;
if(S && S.options[S.selectedIndex].value != "none") {
url = S.options[S.selectedIndex].value
if(!truc || truc.closed)
truc = window.open('','','width=700,height=550,resizable=1');
truc.location = url;
truc.focus();
}
}
</script>
<script type="text/javascript">
<!--
document.write('<form name="selecter1"><select name="select1" size=1>');
document.write('<option value=none>Test');
document.write('<option value=none>--------------------');
document.write('<option value="http://www.a.null">A');
document.write('<option value="http://www.b.null">B');
document.write('<option value="http://www.c.null">C');
document.write('<option value="http://www.d.null">D');
document.write('</select>');
document.write('<input type="button" value="Go" onclick="go1()">');
document.write('</form>');
// end hiding contents -->
</script>

Hey thanks!

But I was looking for a new browser window/tab not a pop-up window.
Something more like the (target="_blank") in regular links.

Can that be possible?


TIA
 
A

ASM

d4rkn1ght a écrit :
Something more like the (target="_blank") in regular links.

<script type="text/javascript">
function go1(){
var f = document.selecter1;
var s = f.select1;
var k = s.selectedIndex;
if(k>1) {
f.action=s.options[k].value;
f.submit();
}
}
</script>
<script type="text/javascript">
<!--
document.write('<form name="selecter1" action="" target="_blank">'+
'<select name="select1" size=1>');
document.write('<option value=none>Test');
document.write('<option value=none>--------------------');
document.write('<option value="test.htm">A');
document.write('<option value="test_1.htm">B');
document.write('<option value="http://www.c.null">C');
document.write('<option value="http://www.d.null">D');
document.write('<\/select>');
document.write('<input type="button" value="Go" onclick="go1()">');
document.write('<\/form>');
// end hiding contents -->
</script>
 
D

d4rkn1ght

d4rkn1ght a écrit :
Something more like the (target="_blank") in regular links.

<script type="text/javascript">
function go1(){
var f = document.selecter1;
var s = f.select1;
var k = s.selectedIndex;
if(k>1) {
f.action=s.options[k].value;
f.submit();
}
}
</script>
<script type="text/javascript">
<!--
document.write('<form name="selecter1" action="" target="_blank">'+
'<select name="select1" size=1>');
document.write('<option value=none>Test');
document.write('<option value=none>--------------------');
document.write('<option value="test.htm">A');
document.write('<option value="test_1.htm">B');
document.write('<option value="http://www.c.null">C');
document.write('<option value="http://www.d.null">D');
document.write('<\/select>');
document.write('<input type="button" value="Go" onclick="go1()">');
document.write('<\/form>');
// end hiding contents -->
</script>

It works! Thank you very much!
 

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,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top