• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2117
  • Last Modified:

onchange="window.open...... not working!

Here is my <select> tag:

<select name="News" size="1" onchange="window.open(this.options[this.selectedIndex].value,'News')">

all the option tags (except the first one, which says "Please select a news release..." and has no value) have the page links in the value. ie: <option value="link1.htm">

Before, the news page was in frames, and this same code used to work (except instead of window.open, it was news_frame(this.options... blah blah).

I've tried everything and nothing seems to work!

Thanks in advance! :)
0
filemanager
Asked:
filemanager
  • 4
  • 4
  • 3
  • +5
1 Solution
 
BustaroomsCommented:
it looks ok to me

think we'll need more code or a url to be able to help
0
 
NetGrooveCommented:
First of all, you can reduce it to this:

<select name="News" size="1" onchange="window.open(this.value,'News')">


Second, your statement "nothing seems to work!" does not describe the error you are getting at all.
Say first what result you are trying to achieve, and then what errors do you get.

0
 
filemanagerAuthor Commented:
Well, I want the value in the option tag (the HTML page) to pop up in a new window, but the code I pasted above, it doesn't do anything for some reason.

The drop down box is slightly long, so I'll only put in the first couple option tags:

<select name="News" size="1" onchange="window.open(this.value,'Enghouse News')">
<option>Please select a news release...</option>
<option value="c_Q32003.htm">Enghouse Q3 Net Income up over 150% - Sept. 10, 2003</option>
<option value="c_Q22003.htm">Enghouse Q2 Revenue and Net Income up over 50% - June 5, 2003</option>
....
</select>

So if you click on any of the news headings, it's supposed to pop up that article in a new window, but no new window appears.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
filemanagerAuthor Commented:
Oh, and here's the <form> tag (in case it helps):

<form method="POST" align="left" name="News_Select" action="" target="_blank">
0
 
BustaroomsCommented:
not to be a jacka$$ but you're not running any popup blockers are you?
0
 
James RodgersWeb Applications DeveloperCommented:
i tested your code with local files on win2k with ie 6 and it worked fine
0
 
filemanagerAuthor Commented:
Not running any popup blockers, no :P
0
 
BustaroomsCommented:
it has to be another part of your code or something.  do you have a url where we can see this
0
 
ren_bCommented:
try using a full uri?..
<select onchange="return window.open('http://domain/dir/'+this.value,'blahblah');">
0
 
devicCommented:
try instead:
Enghouse News
this:
EnghouseNews

;)
0
 
devicCommented:
here is with space :)
=========================
<select name="News" size="1" onchange="mywin=window.open(this.value);mywin.document.title='Enghouse News'">
<option>Please select a news release...</option>
<option value="c_Q32003.htm">Enghouse Q3 Net Income up over 150% - Sept. 10, 2003</option>
<option value="c_Q22003.htm">Enghouse Q2 Revenue and Net Income up over 50% - June 5, 2003</option>
....
</select>
0
 
ren_bCommented:
you still have to use a full uri...
you cannot open your browser and type "c_Q32003.htm" and expect it to know where to go can you? no.

if the values on the options were something like "http://blah.com/c_Q32003.htm" then it would work fine.

you could do as ive said earlier, or do that in a function for window.open:

function openWin(lc,nm)
{
  var path = "http://www.experts-exchange.com/" //should be whats relevant to you
  return window.open(path+lc,escape(nm));          //escape(nm) clears up the spaces if there are any:
                                                                         //    Enghouse News > Enghouse%20News
}
0
 
ren_bCommented:
here would be a small application:

<html>
<head>
<script type="text/javascript">
<!--
function openWin(lc,nm)
{
  if(lc==0) return false;
  else
  {
    var path = "http://www.experts-exchange.com/
    window.open(path+lc,escape(nm));        
  }
}
//-->
</script>
</head>
<body>
<form>
<select onchange="openWin(this.value,'Enghouse News');">
<option value=0>Please Select a Site</option>
<option value="Web/">Web</option>
<option value="Web/Web_Languages/">Web Languages</option>
<option value="Web/Web_Languages/Javascript/">Javascript</option>
<option value="Web/Web_Languages/PHP/">PHP</option>
<option value="Web/Web_Languages/CSS/">CSS</option>
</select>
</form>
</body>
</html>
0
 
devicCommented:
@ ren_b,
it would be nice, if you check your script, before post it.
0
 
incongruentCommented:
the url should still work with a relative path.  It has when I've used it.

0
 
ren_bCommented:
the script works fine, ie just doesn't handle it right: it won't allow % in the name whereas mozilla does which i tested it on, sorry. if the name were just EnghouseNews itd be fine. i don't know what the problem could be... it has to be something esle than what he's given us.
0
 
devicCommented:
yea, Mozilla is good, but 96% is IE, and MUST in IE work ;)
0
 
vknowlesCommented:
It looks like the problem is the use of the Name attribute to try to establish the window title.

From what I recall, the Name attribute is rather vaguely defined in the standards and different browsers can treat it in different ways.  Using the second parameter in the window.open method is risky.

I like devic's method of setting the window title explicitly after you open it.

-Van
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 4
  • 3
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now