Solved

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

Posted on 2003-11-26
18
2,110 Views
Last Modified: 2006-11-17
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
Comment
Question by:filemanager
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +5
18 Comments
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9827398
it looks ok to me

think we'll need more code or a url to be able to help
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9827462
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
 

Author Comment

by:filemanager
ID: 9827508
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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 

Author Comment

by:filemanager
ID: 9827520
Oh, and here's the <form> tag (in case it helps):

<form method="POST" align="left" name="News_Select" action="" target="_blank">
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9827525
not to be a jacka$$ but you're not running any popup blockers are you?
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9827538
i tested your code with local files on win2k with ie 6 and it worked fine
0
 

Author Comment

by:filemanager
ID: 9827558
Not running any popup blockers, no :P
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9827630
it has to be another part of your code or something.  do you have a url where we can see this
0
 
LVL 6

Expert Comment

by:ren_b
ID: 9827681
try using a full uri?..
<select onchange="return window.open('http://domain/dir/'+this.value,'blahblah');">
0
 
LVL 25

Accepted Solution

by:
devic earned 50 total points
ID: 9827744
try instead:
Enghouse News
this:
EnghouseNews

;)
0
 
LVL 25

Expert Comment

by:devic
ID: 9827770
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
 
LVL 6

Expert Comment

by:ren_b
ID: 9828097
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
 
LVL 6

Expert Comment

by:ren_b
ID: 9828152
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
 
LVL 25

Expert Comment

by:devic
ID: 9828182
@ ren_b,
it would be nice, if you check your script, before post it.
0
 
LVL 2

Expert Comment

by:incongruent
ID: 9828337
the url should still work with a relative path.  It has when I've used it.

0
 
LVL 6

Expert Comment

by:ren_b
ID: 9828473
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
 
LVL 25

Expert Comment

by:devic
ID: 9828487
yea, Mozilla is good, but 96% is IE, and MUST in IE work ;)
0
 
LVL 1

Expert Comment

by:vknowles
ID: 9829530
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

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question