/    Sign up×
Community /Pin to ProfileBookmark

Placement of ‘newWin’ command?

Hi,

The following is a very tiny sample script in which I would like the selected results to open in a new window.

All I need is for someone to put that command in the right place, and unfortunately, I don’t even know what the command should look like.

My gratitude and a handshake to whoever answers.

I’m quite sure it will be in the <head></head> section, but here ya go:

[code=php]<html>

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=windows-1252″>

<title>New Page 1</title>

<script type=”text/javascript”><!–

function surfto(n){
eval(‘th=document.getElementById(“form’+n+'”).select;’);
if(th.options.selectedIndex!=0){
location.href=th.options[th.selectedIndex].value;}}

//–></script>

</head>

<body>

<p align=”center”>

<form id=”form1″>
<select id=”select” onchange=”surfto(‘1’)”>
<option selected=”selected”>Select Item—>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
<option value=”http://www.google.com”>Google</option>
</select>
</form>

<p>

<form id=”form2″>
<select id=”select” onchange=”surfto(‘2’)”>
<option selected=”selected”>Select Item—>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
<option value=”http://www.yahoo.com”>Yahoo</option>
</select>
</form>

<p>

<!– Notice the two event handlers; onchange=”surfto(‘1’)” and onchange=”surfto(‘2’)”.
Make sure that the numbers in them are the same as the numbers in the appropraite form id; id=”form1″ and id=”form2″. –>

</body>

</html>[/code]

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Jul 13.2006 — there is no such thing as newWin. I am guessing you are talking window.open.

<select onchange="window.open(this.options[this.selectedIndex].value);"

Eric
Copy linkTweet thisAlerts:
@PoopyPantsauthorJul 13.2006 — Okay, well the only two examples I could find to open a new window looked like this:

if (i>=0) window.open(options[i].value,'newWin');



and this:



window.open ('page.html')



But neither of them are relevant to this present script in question, and I see now that I called it the wrong thing. So thank you for correcting me.



I would still like to know where to place the command that you've given, if it is in fact the command that works with this script.



Forgive my ignorance.
Copy linkTweet thisAlerts:
@A1ien51Jul 13.2006 — hmmmmmmm.......

replace where the page is replaceing the location.href with this:

var newWin = window.open(th.options[th.selectedIndex].value;,'newWin');

}}

it goes

window.open(url,referenceName,properties)

Just search the net for a JavaScript reference or pick up a book. You are talking about basics here.


Eric
Copy linkTweet thisAlerts:
@PoopyPantsauthorJul 13.2006 — Thank you Eric.
Copy linkTweet thisAlerts:
@James_GatkaJul 13.2006 — [CODE]<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>New Page 1</title>

<script type="text/javascript"><!--

var newWin = "";

function surfto(nHref){

if (nHref != "")
{
if (newWin != ""){newWin.close()}
newWin = window.open(nHref,'surf','toolbar=1,menubar=0,statusbar=0,scrollbars=1,resizable=1,top=50,left=200');
}
}

//--></script>

</head>

<body>

<p align="center">

<form>
<select id="select" onchange="surfto(this.value)">
<option selected="selected">Select Item--->&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
<option value="http://www.google.com">Google</option>
<option value="http://www.yahoo.com">Yahoo</option>
</select>
</form>

</p>

</body>

</html> [/CODE]
Copy linkTweet thisAlerts:
@PoopyPantsauthorJul 13.2006 — That was actually pretty crazy. It didn't do the right thing, but it did something, and that's better than nothing.
Copy linkTweet thisAlerts:
@James_GatkaJul 13.2006 — [B]<select id="select" onchange="surfto(this.value)">[/B]
Copy linkTweet thisAlerts:
@PoopyPantsauthorJul 13.2006 — Slam freakin' dunk.

You rock James.
×

Success!

Help @PoopyPants spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...