我在尝试使用headScript()->appendFile('file name')Zend 附加javascript文件时遇到问题.我的布局设置如下:
<?= $this->headScript()
->prependScript( 'BASE_URL = "' . $this->baseUrl() . '";' )
->appendFile( $this->baseUrl('js/lib/jquery/jquery-1.4.2.min.js') )
->appendFile( $this->baseUrl('js/admin.js') );
?>
Run Code Online (Sandbox Code Playgroud)
然后,在我的控制器中,我试图仅为此页面附加一个额外的js文件,如:
$this->view->headScript()->appendFile( 'another/js/file.js' );
Run Code Online (Sandbox Code Playgroud)
此文件需要附加到布局中已设置的内容.但是,此文件会在其他"appendFile"文件之前添加.我也试过了
$this->headScript()->offsetSetFile(999, '/js/myfuncs.js');
Run Code Online (Sandbox Code Playgroud)
但是这仍然会在其他文件之前添加该文件.这不是我期望它的工作方式,特别是在使用offsetSetFile方法时.如何在其他文件之后添加此 文件?谢谢.
我试图使用JavaScript替换文本文件中的一行。
这个想法是:
var oldLine = 'This is the old line';
var newLine = 'This new line replaces the old line';
Run Code Online (Sandbox Code Playgroud)
现在,我想指定一个文件,找到oldLine并用替换newLine并保存。
有人可以在这里帮助我吗?