By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,290 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

Opening New Windows/Tabs

P: n/a
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
--
http://www.3macsandaprinter.uni.cc/
Nov 18 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/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();
}
}
</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>


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 18 '06 #2

P: n/a
in article 45***********************@news.orange.fr, ASM at
st*********************@wanadoo.fr.invalid wrote on 11/18/06 6:42 PM:
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
--
http://www.3macsandaprinter.uni.cc/
Nov 19 '06 #3

P: n/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>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 19 '06 #4

P: n/a
in article 45**********************@news.orange.fr, ASM at
st*********************@wanadoo.fr.invalid wrote on 11/18/06 8:39 PM:
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!
--
http://www.3macsandaprinter.uni.cc/
Nov 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.