在我的应用程序(使用Zend Framework)中,我有一个包含<head>部分的布局文件(layout.phtml),其中包含一些javascripts:
<head>
// Some code
<?php include('template/javascript.php') ?>
</head>在javascript.php中,我有:
<?php
print '<script type="text/javascript;
src="'.PASTA_JAVASCRIPT.DS_URL.'jquery'.DS_URL.'jquery.js" ></script>';
print '<script type="text/javascript;
src="'.PASTA_JAVASCRIPT.DS_URL.'application.js" ></script>';
// More code问题是,当我使用Firefox时,所有这些脚本都正确加载并且可以使用。但当使用Google Chrome时,除了在html头上呈现它们之外,我不能使用jquery或我在application.js上定义的任何其他变量。
我需要提到的另一点是,如果我删除php include代码,并像下面的代码一样手动设置<head>标记内的脚本,它就会像一个护身符一样工作:
<head>
<script type="text/javascript"
src="/path/to/my/scripts/jquery.js"></script>
</head>我所能想到的就是Php的print/echo或者Google Chrome的一些疯狂的行为来解释事物……说真的我真的不知道。
有人知道可能是什么导致了这种行为吗?
发布于 2013-01-16 03:20:44
看起来像是分号问题..
javascript.php -试试这个
<?php
print '<script type="text/javascript" src="'.PASTA_JAVASCRIPT.DS_URL.'jquery'.DS_URL.'jquery.js" ></script>';
print '<script type="text/javascript"
src="'.PASTA_JAVASCRIPT.DS_URL.'application.js" ></script>';或者使用echo
<?php
echo '<script type="text/javascript" src="'.PASTA_JAVASCRIPT.DS_URL.'jquery'.DS_URL.'jquery.js" ></script>';
echo '<script type="text/javascript"
src="'.PASTA_JAVASCRIPT.DS_URL.'application.js" ></script>';https://stackoverflow.com/questions/14343756
复制相似问题