0

I am scripting some buttons whose onclick command loads an external html file and changes the src of an image. However, upon opening the .html file in a browser I'm met with all of my javascript code showing in plain-jane ASCII, clearly unexecuted! :(

EDIT Fixed the problem with the "script type" command. Now, It seems as though the script itself is not executing at all. Any suggestions about what may be going wrong?

Here's the code:

<script='javascript'>

/*image preloader*/

incompanyImage = new Image(); 
incompanyImage.src = " http://us.123rf.com/400wm/400/400/dotshock/dotshock1211/dotshock121100869/16581370-group-of-happy-young-business-people-in-a-meeting-at-office.jpg"; 
/*alt image 1: http://www.123rf.com/photo_16522931_group-of-happy-young-business-people-in-a-meeting-at-office.html */
/*img source: http://www.123rf.com/photo_16581370_group-of-happy-young-business-people-in-a-meeting-at-office.html */

grupoImage = new Image(); 
grupoImage.src = " http://us.123rf.com/400wm/400/400/dotshock/dotshock1209/dotshock120901786/15403105-business-people-team-group-on-a-meeting-have-success-and-make-deal.jpg";
/*img source: http://www.123rf.com/photo_15403105_business-people-team-group-on-a-meeting-have-success-and-make-deal.html */
/*alt images */

particularImage = new Image(); 
particularImage.src = "http://us.123rf.com/400wm/400/400/auremar/auremar1210/auremar121001327/15672624-concerned-business-associates.jpg";
/*img source: http://www.123rf.com/photo_15672624_concerned-business-associates.html */
/*alt images  */

intensivoImage = new Image();
intensivoImage.src = "http://us.123rf.com/400wm/400/400/dotshock/dotshock1211/dotshock121100861/16581384-group-of-happy-young-business-people-in-a-meeting-at-office.jpg";
/*img source male:  http://www.123rf.com/photo_16580996_portrait-of-a-handsome-young-business-man-on-a-meeting-in-offce-with-colleagues-in-background.html */
/*img source female:  http://www.123rf.com/photo_16581362_business-woman-with-her-staff--people-group-in-background-at-modern-bright-office-indoors.html */

tecnicoImage = new Image();
tecnicoImage.src = "http://us.123rf.com/400wm/400/400/dotshock/dotshock1211/dotshock121100861/16581384-group-of-happy-young-business-people-in-a-meeting-at-office.jpg";
/*img source : http://www.123rf.com/photo_16581384_group-of-happy-young-business-people-in-a-meeting-at-office.html */
/*alt image: */


entrevistaImage = new Image();
entrevistaImage.src = "http://us.123rf.com/400wm/400/400/dotshock/dotshock1211/dotshock121100912/16581362-business-woman-with-her-staff--people-group-in-background-at-modern-bright-office-indoors.jpg";
/* img source: http://www.123rf.com/photo_16581362_business-woman-with-her-staff--people-group-in-background-at-modern-bright-office-indoors.html */
/* alt image (better): http://www.123rf.com/photo_16523034_group-of-happy-young-business-people-in-a-meeting-at-office.html */
/*http://www.123rf.com/photo_16523034_group-of-happy-young-business-people-in-a-meeting-at-office.html */

palestraImage = new Image();
palestraImage.src = "http://us.123rf.com/400wm/400/400/dotshock/dotshock1204/dotshock120400224/13112547-young-male-business-man-giving-a-presentation-at-a-meeting-seminar-at-modern-conference-room-on-a-ta.jpg";  
/*img source: http://www.123rf.com/photo_13112547_young-male-business-man-giving-a-presentation-at-a-meeting-seminar-at-modern-conference-room-on-a-ta.html */


/*these are the buttons for types of english classes offered*/
functon buttonInCompany()
{
$('#desc').load('incompany.html');
document.images["midimg"].src = incompanyImage.src;
}

functon buttonGrupo()
{
$('#desc').load('grupo.html');
document.images["midimg"].src = grupoImage.src;
}

functon buttonParticular()
{
$('#desc').load('particular.html');
document.images["midimg"].src = particularImage.src;
}

functon buttonIntensivo()
{
$('#desc').load('intensivo.html');
document.images["midimg"].src = intensivoImage.src;
}

function buttonEntrevista()
{
$('desc').load('entrevista.html');
document.images["midimg"].src = entrevista.html;    
}    

functon buttonTecnico()
{
$('#desc').load('tecnico.html');
document.images["midimg"].src = tecnicoImage.src;
}

function buttonPalestra()
{
$('#desc').load('palestra.html');
document.images["midimg"].src = palestraImage.src;
}

</script>

Now comes the HTML.

<div>
    <p style="text-align: center;"><img name="midimg" width="233" height="350"  class="art-lightbox" src="images/Fotolia_5170186_X-01.jpg"><br></p>
</div>
<div>
    <p class="desc" name="desc">hasdf</p>
</div>
  <div class="art-button" onClick:"buttonParticular()">Aulas Particulares</div>
  <div class="art-button" onClick:"buttonGrupo()">Aulas em Grupo</div>
  <div class="art-button" onClick:"buttonInCompany()">Aulas in-Company</div>
  <div class="art-button" onClick:"buttonIntensivo()">Aulas Intensivos</div>
  <div class="art-button" onClick:"buttonEntrevista()">Aulas para Entrevista</div>
  <div class="art-button" onClick:"buttonTecnico()"> Aulas sobre sua Area</div>
  <div class="art-button" onClick:"buttonPalestra()">Palestras</div>

What am I doing wrong?

Thanks in Advance.

4

2 回答 2

1

The problem (as others have commented, but not posted as answers) is your opening <script='javascript'>. You're looking for:

<script type='text/javascript'>

also: some of your function declarations are misspelled 'functon'

and you should follow the onclick with an = instead of a :

<div onclick="...">
于 2013-01-30T17:31:30.637 回答
0

Simply change <script='javascript'> to <script type='javascript'>. Because of no space after script browse get a tag called script='javascript' (which is not familiar to it) instead of script

Also:

<div class="art-button" onClick:"buttonParticular()">Aulas Particulares</div>

should be

<div class="art-button" onClick="buttonParticular()">Aulas Particulares</div>

In html, you should place = between attribute name (onclick in your case) and value ("buttonParticular()")

于 2013-01-30T17:31:24.127 回答