[英]Codeigniter: page background won't load upon submit error
我有一個登錄頁面,其中包含一個簡單的js
文件,該文件將加載<body>
背景圖像。 如果我只是打開此登錄頁面,則一切正常。 但是,當發生登錄錯誤或注冊錯誤時,該頁面將不會加載背景圖像。 登錄頁面將按以下方式加載到welcome控制器中:
public function index()
{
$this->load->view('index');
}
並在登錄/注冊控制器中加載相同的頁面,如下所示:
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 /現金流/ index.php的
因此,如何運行js
文件,以便加載背景圖片。
謝謝,
也許您必須查看您的js
或images
文件的網址路徑。
您在正確的位置找到js
嗎? 就如:
<script url="<?php echo base_url('path/to/js.js');?>"></script>
請注意,路徑js
當您訪問鏈接文件//localhost:8080/cashflow/index.php/login/index
路徑是一樣的,你訪問鏈接//localhost:8080/cashflow/index.php
。
這樣,您應該檢查在body
標簽中設置的images
背景的url路徑,是否像style="background: url(/path/to/background.jpg) center top norepeat;"
?
請注意,該路徑必須完全指向您選擇的image
或js
。
希望能有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.