0

这是我到目前为止的代码:

`<!DOCTYPE html>
<html>
<head>
</head>
<body>

<img src="http://blog.dubspot.com/files/2011/09/dubspot-dj-producer-banner-2.jpg" alt="electronicmusic" width="1350" height="250">

<h1>Electronic Music Sampler</h1><br>

<p>Select a Genre for a Sample</p>

<form> 
<select id="select" onChange="window.open(this.options[this.selectedIndex].value,'_parent')">
  <option value="genre">Select Genre</option>
  <option value="https://www.youtube.com/watch?v=swxJXT1hjRs">Ambient</option>
  <option value="https://www.youtube.com/watch?v=JRftXCiqfQ8">Breakbeat</option> 
  <option value="https://www.youtube.com/watch?v=rgoz_cPEM8A">Chiptune</option>
  <option value="https://www.youtube.com/watch?v=6gmGJvAc-ws">Downtempo</option>
  <option value="https://www.youtube.com/watch?v=dD40VXFkusw">Drum and Bass</option>
  <option value="https://www.youtube.com/watch?v=5NV6Rdv1a3I">Electro House</option>
  <option value="https://www.youtube.com/watch?v=6GqRsmffeVI">Electronica</option>
  <option value="https://www.youtube.com/watch?v=aMimeO279YE">Electronic Rock</option>
  <option value="https://www.youtube.com/watch?v=84TYi3FOMlU">House</option>
  <option value="https://www.youtube.com/watch?v=vOC35uVlQ7U">Industrial</option>
  <option value="https://www.youtube.com/watch?v=lhuqYgjp7PQ">Progressive Electronic</option>
  <option value="https://www.youtube.com/watch?v=wQnGLHOYnck">Techno</option>
  <option value="https://www.youtube.com/watch?v=atFTgQOF-cU">Trance</option>
  <option value="https://www.youtube.com/watch?v=FMdXOqq3WL4">Dubstep</option>
  <option value="https://www.youtube.com/watch?v=XvLAKrVbCBM">IDM</option>
  <option value="https://www.youtube.com/watch?v=fIea0zMPXik">Glitch</option>
</select> 
</form><br>

<p>Select an Artist for a Discography</p>

<form>
<select id="discographies" name="select" onChange="window.open(this.options[this.selectedIndex].value,'_parent');">
  <option value="discography">Select Artist</option>
  <option value="https://en.wikipedia.org/wiki/Richard_D._James_discography">Aphex Twin</option>
  <option value="https://en.wikipedia.org/wiki/Bassnectar#Discography">Bassnectar</option>
  <option value="https://en.wikipedia.org/wiki/Nullsleep#Discography">Nullsleep</option>
  <option value="https://en.wikipedia.org/wiki/Zero_7_discography">Zero 7</option>
  <option value="https://en.wikipedia.org/wiki/Rusko_(musician)#Discography.5B8.5D">Rusko</option>
  <option value="https://en.wikipedia.org/wiki/Daft_Punk_discography">Daft Punk</option>
  <option value="https://en.wikipedia.org/wiki/The_Chemical_Brothers_discography">The Chemical Brothers</option>
  <option value="https://en.wikipedia.org/wiki/Celldweller_discography">Celldweller</option>
  <option value="https://en.wikipedia.org/wiki/Deadmau5_discography">deadmau5</option>
  <option value="https://en.wikipedia.org/wiki/Nine_Inch_Nails_discography">Nine Inch Nails</option>
  <option value="https://en.wikipedia.org/wiki/Feed_me#Discography">Feed Me</option>
  <option value="https://en.wikipedia.org/wiki/Fatboy_Slim_discography">Fatboy Slim</option>
  <option value="https://en.wikipedia.org/wiki/Kaskade#Discography">Kaskade</option>
  <option value="https://en.wikipedia.org/wiki/Skrillex_discography">Skrillex</option>
  <option value="https://en.wikipedia.org/wiki/Squarepusher#Discography">Squarepusher</option>
  <option value="https://en.wikipedia.org/wiki/KOAN_Sound">Koan Sound</option>
</select>
</form><br>

<p>Did you find this webpage helpful?</p>

<form action="http://www.hirebilinguals.com/wp-content/uploads/2013/02/Thank-You-400x304.jpg" method="get">
<input type="radio" name="answer" value="yes">Yes<br>
<input type="radio" name="answer" value="no">No<br>
<input type="submit" name="submit" value="Submit">
</form>

</body>
</html>`

这是计算机科学入门课程的课程,这是我需要完成的项目的最后一步。When the first option in the dropdown is selected, it tries to go to a different URL, but because I have not identified a URL for it to go to, it just opens a "Webpage not found" page. 我只需要下拉菜单中的第一个选项不执行任何操作,但所有其他选项都会打开我指定的页面。

4

1 回答 1

1

改变

window.open(this.options[this.selectedIndex].value,'_parent')

if (this.selectedIndex > 0) window.open(this.options[this.selectedIndex].value,'_parent')
于 2013-05-14T17:51:20.557 回答