JavaScript not loading


#1

Hello. I want to include some external JavaScript in one of my web pages, via a . The file is in the same directory as the web page itself. I’ve tried the name as shown, and fully qualified. In no case is the file actually included.

I contacted Dreamhost with the question, and they immediately responded that it’s my problem - although the same code works at another web host. Not a dreamy response. Oh well. Has anyone out there had success in including JavaScript in pages this way?

Thanks.


#2

Obvious question: Are you certain that the .js file exists in the right location?


#3

Yeah, heh. I even copied the file name from the page and pasted it into my vi command.[hr]
An addendum: If I put [font=Courier][/font] tags around the .js file code and include it with [font=Courier]<?php include("myscript.js"); ?>[/font], it works fine.

I’m still troubled by the failure of the normal way to include JavaScript, though. DreamHost claims that it’s my fault. If it is, I’d like to know what I’m doing wrong. If it’s not, they should know they’ve got a problem. Any thoughts from you smart people?


#4

We certainly aren’t doing anything specific to keep JavaScript from working. We’d be hearing about it constantly if we were. :slight_smile:

Can you post (or PM me) a link to a page that’s having this problem?


#5

Hang on. Digging around your site a bit, it looks like your JS files themselves contain tags internally. This is incorrect, and will make most browsers refuse to load them. Try removing those and trying again.


#6

The tags weren’t the problem. I added them because of the problem, so that the PHP includes would work. However, I removed the tags and tried including them in the page section again. Behold, this time it worked.

I’m gratified that it’s working, but suspicious about what happened internally to make the exact same tag (pasted from a previous version of the source) fail before and work now.

I guess I’ll just have to say “oh well” again for now. I hope that external JavaScript continues to work for me, and that no other odd little problems arise. Suspicious, suspicious …


#7

I would imagine it’s frowned upon, however, I am having a similar issue.

I’ve recently moved my site over to a vps and have had some javascript issues when we previously had none.

the site in question is tjhl.hockeysim.ca.

The notable issues are:

  • table of contents javascript is not expanding / contracting
  • the news ticker at the top of the page does not load

I was hoping this thread would have offered a solution other than “oh well” so I could try it for myself. I did try saying “oh well” out loud, but it didn’t work out too well… I’ll be sleeping on the couch tonight.

Does anyone have any insight as to what this issue is?