在zendframework中包含javascript的错误

时间:2013-06-24 12:29:28

标签: php zend-framework

我的login.phtml(查看页面)

    <head>
       <? $this->HeadScript()->appendFile('../public/js/jquery-2.0.2.min.js','text/javascript');
        $this->HeadScript()->appendFile('../public/js/clck.js','text/javascript');?>
    </head>

    <body onload="startTime">

    <div id="wrapper">

        <div id="header">
            <link rel="stylesheet" type="text/css" href="../images/mystyle.css">

            <h2>Employee Login</h2>
            <hr>
            <h4 align="left"><?echo "Date:". date('d-m-Y H-ia'); ?> </h4>


        </div>

        <div id="content">
            <?php
            if(isset($this->errorMessage))
            {
                echo $this->errorMessage;
            }
            ?>
            <table align="center"><tr><td>  <? echo $this->form;?></tr></table>

            <a href="<?=$this->url(array('controller'=>'Login','action'=>'signup'))?>">New users ?click here</a><br>
            <a href="<?=$this->url(array('controller'=>'Adminlogin','action'=>'adminlogin'))?>">Admin Login</a>

        </div>

        <div id="footer">
            <p>Copyright (c) 2010 quickstart.com All rights reserved</p>
        </div>

    </div>

    </body>

我的layout.phtml页面

<?php echo $this->layout()->content;?>

<?php echo $this->headScript()->prependFile(
    $this->baseUrl('../public/js/clck.js')) ?>

<?php echo $this->headLink()->prependStylesheet(
    $this->baseUrl('../public/images/mystyle.css'))?>



<?php echo $this->inlineScript()->prependFile(
    '../public/js/jquery-2.0.2.min.js') ?>

my js page clck.js

function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout(function(){startTime()},500);
}

function checkTime(i)
{
if (i<10)
{
    i="0" + i;
}
return i;
}

我的application.ini

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.db.adapter = "PDO_MYSQL"
resources.db.params.dbname = "test"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = "mysql"


 resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

我的bootstarp文件     

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

protected function _initPlaceholders()
{
}
}

?>
<?php
set_include_path('../quickstart/application/models'.get_include_path());
?>

我在bootstrap或application.ini中有任何设置吗? 我试图将javascript文件包含在查看页面中。但它不起作用。 css工作正常。

1 个答案:

答案 0 :(得分:0)

我尝试使用视图页面上的代码(login.phtml):

SRC =“/的Zend /公共/ JS / clck.js

它适用于浏览页面。