我有一个登录页面,其中包括一个简单的js
文件,将加载<body>
背景图像。如果我只是打开这个登录页面,一切工作正常。但是当发生登录错误或注册错误时,页面将不会加载背景图像。在欢迎控制器中像这样加载登录页面:
public function index()
{
$this->load->view('index');
}
和相同的页面加载到login/register控制器中,如下所示:
if ($this->form_validation->run() == FALSE)
{
// validation fail
$data = array(
'error_message' => 'Please check your inputs.'
);
$this->load->view('index', $data);
}
我确实注意到,当提交错误发生时,重新加载的索引页的url是http://localhost:8080/cashflow/index.php/login/index而正常的索引页url应该是http://localhost:8080/cashflow/index.php
那么,我怎么能有js
文件运行,使背景图像将被加载。
谢谢,
也许您必须检查您的js
或images
文件的url路径。
你找到你的js
正确的地方吗?就像:
<script url="<?php echo base_url('path/to/js.js');?>"></script>
请注意,当您访问链接//localhost:8080/cashflow/index.php/login/index
路径时,js
文件的路径与访问链接//localhost:8080/cashflow/index.php
的路径相同。
这样,你应该检查body
标签中设置的images
背景的url路径,它是否像style="background: url(/path/to/background.jpg) center top norepeat;"
?
请注意,路径必须指向您选择的image
或js
。