Why is JavaScript working from inside not from .js file!

Hello,

We are doing some Text rolling via JavaScript, it works fine when the JS code is included inside the file, as you can see here:

but it does not work when the same exact JS is loaded via an included .js file, as you can see here:

What is going on! Why is JS not working when it is being loaded via .js file?

I must say as a tiny tiny organization, we hate these wierd JS and CSS stuff :slight_smile:
Thanks,

I don’t see where you linked to the javascript file in the second example. Or did you actually use a PHP include(); to load the javascript file? I’ve never seen it done that way before.

There are no <script> tags supposed to be in the actual .js file – that’s HTML. BTW when you don’t know what’s going on, you might just check the console for errors… it says:

Uncaught SyntaxError: Unexpected token <

3 Likes

Yes, that was it. That is once we removed the tags from the .js file, then it is loading OK!
But wierd thing is that we tried that, and it was not. However having tried it again as per your message, now it is!

BTW, what is the best software you recommend using for viewing JS Errors? Beside Firbugs?

Thanks,

AFAIK most if not all modern browser have some form of “dev tools”

With your browser open to a page try pressing F12 if you can’t find it in the menu.

Yes, I am aware of that. But when you do that you get all sort of other things.
So a good JavaScript debugger, would be so good and I think so appreciated and in demand.

True enough. So many that I certainly don’t know everything that is possible let alone how to use everything.

Some features are evident, others you have to know they’re there to know they’re there.

I usually use the “console” to help let me know where to look.
And sometimes the “CLI” (whatever it’s called) to determine values.

The “breakpoints” let you step through the code allowing you to see what values are at those points in the code.

WOW! That is most impressive use of GIF Animation I have seen in a long time :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.