Solved

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

Posted on 2003-11-26
18
2,095 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
  • 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
 

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
date format angularjs2 16 43
C3-->D3 Line Chart 4 19
addressing a specific html page 9 29
jqplot Pie Chart - javascript 2 18
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now