attaching js files to one js file but with JQuery error !

Posted by uzay95 on Stack Overflow See other posts from Stack Overflow or by uzay95
Published on 2010-03-31T06:11:30Z Indexed on 2010/03/31 6:13 UTC
Read the original article Hit count: 500

Filed under:
|
|

Hi, I wanted to create one js file which includes every js files to attach them to the head tag where it is.

But i am getting this error

Microsoft JScript runtime error: Object expected

this is my code:

var baseUrl = document.location.protocol + "//" + document.location.host + '/yabant/';

// To find root path with virtual directory
function ResolveUrl(url) {
    if (url.indexOf("~/") == 0) {
        url = baseUrl + url.substring(2);
    }
    return url;
}

// JS dosyalarinin tek noktadan yönetilmesi
function addJavascript(jsname, pos) {
    var th = document.getElementsByTagName(pos)[0];
    var s = document.createElement('script');
    s.setAttribute('type', 'text/javascript');
    s.setAttribute('src', jsname);
    th.appendChild(s);
}

addJavascript(ResolveUrl('~/js/1_jquery-1.4.2.min.js'), 'head');
$(document).ready(function() {
    addJavascript(ResolveUrl('~/js/5_json_parse.js'), 'head');
    addJavascript(ResolveUrl('~/js/3_jquery.colorbox-min.js'), 'head');
    addJavascript(ResolveUrl('~/js/4_AjaxErrorHandling.js'), 'head');
    addJavascript(ResolveUrl('~/js/6_jsSiniflar.js'), 'head');

    addJavascript(ResolveUrl('~/js/yabanYeni.js'), 'head');
    addJavascript(ResolveUrl('~/js/7_ResimBul.js'), 'head');
    addJavascript(ResolveUrl('~/js/8_HaberEkle.js'), 'head');
    addJavascript(ResolveUrl('~/js/9_etiketIslemleri.js'), 'head');
    addJavascript(ResolveUrl('~/js/bugun.js'), 'head');
    addJavascript(ResolveUrl('~/js/yaban.js'), 'head');
    addJavascript(ResolveUrl('~/embed/bitgravity/functions.js'), 'head');
});

Paths are right. I wanted to show you folder structure and watch panel: alt text

Any help would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript