baseURL fix in IE

2019-08-10 01:23发布

I'm developing a website with following structure: click here. And I'm having some problems with the URL when trying to load stylesheets. Being more specific, in the admin module I'm using this bootstrap:

<?php

class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
    public function _initResources() {
        $view = new Zend_View();
        $view->headScript()
                ->appendFile('public/js/jquery-1.4.2.min.js')
                ->appendFile('public/js/jquery.tools.min.js')
                ->appendFile('public/js/jquery-ui-1.8.4.custom.min.js')
                ->appendFile('public/js/utils.js')
                ->appendFile('public/ckeditor/ckeditor.js')
                ->appendFile('public/ckeditor/adapters/jquery.js')
                ->appendFile('public/js/admin.js')
                ->appendFile('public/js/ie.utils.js', null, array('conditional' => 'IE'))
                ->appendFile('public/js/ie.js', null, array('conditional' => 'IE'));

        $view->headLink()
                ->appendStylesheet('public/css/blueprint/screen.css', 'screen')
                ->appendStylesheet('public/css/uploadify.css', 'screen')
                ->appendStylesheet('public/css/jquery.tools.css', 'screen')
                ->appendStylesheet('public/css/ui-theme/jquery-ui-1.8.4.custom.css', 'screen')
                ->appendStylesheet('public/css/blueprint/print.css', 'print')
                ->appendStylesheet('public/css/admin.css', 'screen')
                ->appendStylesheet('public/css/blueprint/ie.css', 'screen', 'IE')
                ->appendStylesheet('public/css/ie.css', 'screen', 'IE');
    }

}

Also I'm using <base href="<?php echo $this->baseUrl(); ?>/" /> which works perfectly for Chrome and Firefox, but in IE I could see that the <base> TAG doesn't work and it uses /ccgss/admin/ as baseUrl instead of /ccgss/ which cause problem when trying to load something in the public folder 'cause it tries to find in /ccgss/admin/public.

Is there any other way to append my resources in the bootstrap or I do need to workaround? How this should be?

2条回答
你好瞎i
2楼-- · 2019-08-10 02:08

One easy solution would be to put a slash in front of those path wich would make them absolute to your websites root.

also from here:

In HTML the tag has no end tag.

In XHTML the tag must be properly closed.

So make sure you set the right doctype.

Also why is your index.php not in the public folder? You know that the public folder really is the public_html folder on a lot of servers.

查看更多
老娘就宠你
3楼-- · 2019-08-10 02:23

try to set paths like that:

 $view->headScript()
                ->appendFile($this->baseUrl() . 'public/js/jquery-1.4.2.min.js');

also try to use google's jquery store: http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

ps: http://code.google.com/intl/en-En/apis/libraries/devguide.html

pss: in my application I use plugins for loading such libraries and I found that it is very useful property for me:

resources.frontController.baseUrl = /test/
查看更多
登录 后发表回答