开发者

Why won't my JS file load?

using this code:

<script src="<?php bloginfo('template_url'); ?>/scripts/hovermenus.js" type="text/javascript"></script>

to load开发者_StackOverflow社区 this script

firebug is not showing this script as loaded, however, these scripts:

<script src="<?php bloginfo('template_url'); ?>/scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="<?php bloginfo('template_url'); ?>/scripts/salf_ui.js" type="text/javascript"></script>
    <script src="<?php bloginfo('template_url'); ?>/scripts/date.js" type="text/javascript"></script>
    <script src="<?php bloginfo('template_url'); ?>/scripts/datePicker.js" type="text/javascript"></script>

all load perfectly well. I have double, triple and quadruple checked the file is in the right directory.


Looks like the problem is with your file

Make sure the file .../scripts/hovermenus.js exists. Navigate there and copy paste the file name from there.

Could the script be in another directory? could it be hoverMenus.js or hover.menus.js.... etc.

If none of this works, try copying and renaming the file. See if you can load the renamed version. If you can't, it's something in the file.

Unrelated: You should declare your variables with var so you don't create a bunch of global variables attached to window.


You see these:
Why doesn't ASP.NET (3.5) always load an external javascript?

Firebug doesn't load JavaScript files or stop execution on breakpoints


charset isnt a valid attribute for the script tag, try removing it

EDIT

Actually it is valid, try removing it anyway :)


Make sure you've closed all your script tags above the one you're trying to load.


I had the similar problem: same file would not load on other pages(master pages)

original: 

   <script type="text/javascript" src="../../Scripts/scriptMob.js"></script>

fixed:    
   <script type="text/javascript" src="/Scripts/scriptMob.js"></script>

only removed dots and first slash

Additionally you can check in firebug(HTML section), expand the reference line

    (+) <script src="../../Scripts/scriptMob.js" type="text/javascript"> 

to check whether browser actually reads the js file correctly.

the error message was saying: [SqlException]: Error converting data type nvarchar to int.


Had a similar problem, shoving my head against a wall trying to figure it out. Turned out the js file had a syntax issue buried in it, something stupid that didn't show in my editor ... in this case it was a hanging 'var ' with nothing after it. As soon as I deleted that, everything was copacetic.

So my recommendation if you run into this is what I did - remove all functions and add them back one by one until you find one that kills it.


Had a similar problem, cant load script /js/search_ads.js It was problem in my adblock extension After renaming to search.js problem was disappearing

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜