Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript预加载程序和load()命令出错_Javascript_Javascript Events - Fatal编程技术网

Javascript预加载程序和load()命令出错

Javascript预加载程序和load()命令出错,javascript,javascript-events,Javascript,Javascript Events,我正在编写一些按钮的脚本,其onclick命令加载外部html文件并更改图像的src。但是,在浏览器中打开.html文件时,我会看到所有javascript代码都以简单的ASCII格式显示,显然未执行!:( EDIT修复了“script type”命令的问题。现在,脚本本身似乎根本没有执行。对可能出现的问题有什么建议吗 代码如下: <script='javascript'> /*image preloader*/ incompanyImage = new Image(); in

我正在编写一些按钮的脚本,其onclick命令加载外部html文件并更改图像的src。但是,在浏览器中打开.html文件时,我会看到所有javascript代码都以简单的ASCII格式显示,显然未执行!:(

EDIT修复了“script type”命令的问题。现在,脚本本身似乎根本没有执行。对可能出现的问题有什么建议吗

代码如下:

<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>

/*图像预加载程序*/
companyimage=新图像();
companyimage.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图像1:http://www.123rf.com/photo_16522931_group-of-happy-young-business-people-in-a-meeting-at-office.html */
/*img来源:http://www.123rf.com/photo_16581370_group-of-happy-young-business-people-in-a-meeting-at-office.html */
grupoImage=新图像();
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来源:http://www.123rf.com/photo_15403105_business-people-team-group-on-a-meeting-have-success-and-make-deal.html */
/*alt图像*/
特殊图像=新图像();
specialimage.src=”http://us.123rf.com/400wm/400/400/auremar/auremar1210/auremar121001327/15672624-concerned-business-associates.jpg";
/*img来源:http://www.123rf.com/photo_15672624_concerned-business-associates.html */
/*alt图像*/
intensivoImage=新图像();
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来源男性:http://www.123rf.com/photo_16580996_portrait-of-a-handsome-young-business-man-on-a-meeting-in-offce-with-colleagues-in-background.html */
/*img来源女性:http://www.123rf.com/photo_16581362_business-woman-with-her-staff--people-group-in-background-at-modern-bright-office-indoors.html */
tecnicoImage=新图像();
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来源:http://www.123rf.com/photo_16581384_group-of-happy-young-business-people-in-a-meeting-at-office.html */
/*alt图像:*/
entrevistaImage=新图像();
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来源:http://www.123rf.com/photo_16581362_business-woman-with-her-staff--people-group-in-background-at-modern-bright-office-indoors.html */
/*alt图像(更好):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=新图像();
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来源: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 */
/*这些是提供的英语课程类型的按钮*/
functon公司()
{
$('#desc').load('company.html');
document.images[“midimg”].src=companyimage.src;
}
functon buttonGrupo()
{
$('#desc').load('grupo.html');
document.images[“midimg”].src=grupoImage.src;
}
functon按钮nParticle()
{
$('#desc').load('special.html');
document.images[“midimg”].src=specialimage.src;
}
functon按钮tensivo()
{
$('#desc').load('intensivo.html');
document.images[“midimg”].src=intensivoImage.src;
}
功能按钮Revista()
{
$('desc').load('entrevista.html');
document.images[“midimg”].src=entrevista.html;
}    
functon buttonTecnico()
{
$('#desc').load('tecnico.html');
document.images[“midimg”].src=tecnicoImage.src;
}
函数按钮Plastera()
{
$('#desc').load('paletra.html');
document.images[“midimg”].src=palestraImage.src;
}
现在是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>


hasdf

特殊奥拉斯 奥拉斯阿姆格鲁波酒店 奥拉斯公司 奥拉斯酒店 奥拉斯帕拉恩特维斯塔酒店 Aulas sobre sua地区 帕莱斯特拉斯
我做错了什么

提前感谢。

只需将
更改为
。由于
脚本
后没有空格,请浏览一个名为
script='javascript'
的标签,而不是
脚本

此外:

Aulas特例
应该是

<div class="art-button" onClick="buttonParticular()">Aulas Particulares</div>
Aulas特例
在html中,您应该将
=
放在属性名(
onclick
在您的例子中)和值(
“buttonnParticle()”

之间。问题(如其他人所评论,但不是作为答案发布)是您的开头
。您正在寻找:

<script type='text/javascript'>

-要么彻底清理这个标签(
在任何有价值的浏览器上都应该足够了),要么用
替换它。首先,将javascript代码放在里面,而不是。太好了,哇,这是一个简单的解决方案!:)尽管现在我可以看到我的按钮也不能正常工作。不知道为什么。函数中的命令有什么问题吗?谢谢andre。另外,您是否注意到函数中的命令有任何问题?是的,有两件事:1)一些
函数
s拼错了'functon',2)应该是
onclick=“…”
谢谢FAngel。另外,您是否注意到函数中的命令有任何问题?他们似乎没有执行。
<script type='text/javascript'>
<div onclick="...">