我安裝我下我的Apache /本地主機/ ci_app子目錄CI/JS動態鏈接指向根/在CI
現在我下/本地主機/ ci_app一些JS文件/資產/ JS/code.js
裏面code.js我加載腳本動態
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "/assets/js/another_script.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'my_other_script'));
在CI配置我有$config['base_url'] = '/ci_app/';
但每次我加載頁面我得到的腳本中調用http://localhost/assets/js/another_script.js
。
我需要的腳本是指向http://localhost/ci_app/assets/js/another_script.js
嘗試讓base_url在配置中爲空,CI在猜測它時非常神。然後,嘗試像這樣調用腳本:js.src =「<?php echo base_url();?> assets/js/another_script.js」;它應該工作... – sinisake
這不會工作。不執行裏面.js – Kal
對不起,沒有仔細閱讀,認爲這是你的看法... – sinisake