【问题标题】:Codeigniter: page background won't load upon submit errorCodeigniter:提交错误时不会加载页面背景
【发布时间】:2017-03-25 04:28:12
【问题描述】:

我有一个登录页面,其中包含一个简单的js 文件,该文件将加载<body> 背景图像。如果我只是打开此登录页面,一切正常。但是当出现登录错误或注册错误时,页面不会加载背景图片。 欢迎控制器中的登录页面是这样加载的:

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/cashflow/index.php

那么,我怎样才能运行 js 文件以便加载背景图像。

谢谢,

【问题讨论】:

    标签: javascript php jquery html codeigniter


    【解决方案1】:

    也许您必须查看您的 jsimages 文件 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;"

    请注意,路径必须完全指向您选择的imagejs

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-16
      相关资源
      最近更新 更多