baseURL fix in IE

狂风中的少年 提交于 2019-12-11 05:46:54

问题


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?


回答1:


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/



回答2:


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.



来源:https://stackoverflow.com/questions/3629791/baseurl-fix-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!