Javascript preloader 和 load() 命令的错误
Errors with Javascript preloader and load() command
我正在编写一些按钮的脚本,其onclick
命令加载外部html文件并更改图像的src。但是,在浏览器中打开.html文件时,我遇到了我所有的JavaScript代码,以纯简ASCII显示,显然未执行!:(
编辑 修复了"脚本类型"命令的问题。现在,脚本本身似乎根本没有执行。关于可能出现的问题的任何建议?
代码如下:
<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>
现在是 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>
我做错了什么?
问题(正如其他人所评论的那样,但没有作为答案发布)是你的开场<script='javascript'>
。您正在寻找:
<script type='text/javascript'>
另外:您的一些function
声明拼写错误为"functon"
您应该用=
而不是:
来遵循onclick
<div onclick="...">
只需将<script='javascript'>
更改为<script type='javascript'>
即可。由于浏览后没有空间script
所以会得到一个名为script='javascript'
(它不熟悉)的标签而不是script
也:
<div class="art-button" onClick:"buttonParticular()">Aulas Particulares</div>
应该是
<div class="art-button" onClick="buttonParticular()">Aulas Particulares</div>
在 html 中,您应该在属性名称(在您的情况下onclick
)和值 ( "buttonParticular()"
) 之间放置=
相关文章:
- 从命令行安装时出现错误
- 尝试从命令行将android平台添加到ionic时,模块.js:341处出现错误
- 命令代码jquery文件错误
- Heroku创建命令屈服“;ENOENT”;错误
- 从 JavaScript 执行 shell 命令时权限被拒绝错误
- 余烬构建命令失败并显示错误:没有这样的文件或目录,lstat ../ember-cli-test-loader/test
- PhantomJS在使用命令行运行任何js时都会出现分段错误
- 量角器由中继器命令中是否有错误
- 错误:找不到控制台中所有 Meteor 命令的模块“下划线”
- Azure Blob 放置命令在以前工作时生成错误
- Cygwin命令给出错误
- 使用 npm 命令时找不到模块“npmlog”错误消息
- 当我运行node app.js命令时,它会给我错误`ENOENT,.mime.types上没有这样的文件或目录
- FTP错误:202命令未实现
- 在尝试运行命令时处理Yeoman自定义生成器中的错误事件
- node.js错误:执行命令行命令时产生ENOSYS
- 从命令行运行jasmine会在es6测试中引发模板错误
- 错误:运行yarn命令时无法获取本地颁发者证书
- 烬你好字-测试错误在http://localhost:4200/tests,但不是在命令行
- 从命令行评估JavaScript文件的运行时/加载错误