PDA

View Full Version : Javascript Error in a basic include


Kaelon
07-08-2005, 09:47 PM
Here's the code of a simple page I'm using just to generate a uniform "look and feel" for some custom content:

<?php

define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'main');

chdir('/full/url/to/my/forumsdir');

require_once('./global.php');

eval('print_output("' . fetch_template('mainpage') . '");');

exit;
?>

... where "mainpage" is a simple template that calls $header and $footer.

Why do I receive Javascript errors? This is in vB3.5 Beta 3.

Andreas
07-08-2005, 10:05 PM
Would be useful to know which JS errors exactly ...

Kaelon
07-08-2005, 10:39 PM
Error on line 2 -- object expected.
Error on line 506 -- object expected.

Andreas
07-08-2005, 10:50 PM
Those errors are (non-meaningful) IE error messages?

Kaelon
07-08-2005, 11:05 PM
Those errors are (non-meaningful) IE error messages?

Yes, correct.

The page still loads correctly, but there's literally not difference between this new template I created and the standard "FORUMHOME" template.

Andreas
07-08-2005, 11:09 PM
Open the Page in Firefox and check if it still generates Errors.
If it does, please post htem (and hopefully they'll be more meaningful then)

Kaelon
07-09-2005, 12:02 AM
Interesting! It doesn't generate errors in Firefox. But it does generate errors in Internet Explorer. I wonder why? The template is identical to the template code for FORUMHOME (which doesn't generate an error). Is the javascript path-specific?

Andreas
07-09-2005, 12:10 AM
No, it shouldn't.

Anyway, IE is crap IMHO ;)

Kaelon
07-09-2005, 02:05 AM
No, it shouldn't.

Anyway, IE is crap IMHO ;)
No disagreement from me there, Kirby =) I just think it's a bit weird that it works fine at forums/index.php, but on /mypage.php with the above code, I get the Java Error. Makes it a bit impractical for my site's target audience (which is commercial users who principally use IE).

Biker_GA
07-09-2005, 02:12 AM
Could it be Microsoft's implementation of Java and what vB actually uses? What happens if you install "real" java from Sun on your PC?

Kaelon
07-09-2005, 02:19 AM
I do have Sun's "real" Java installed. (JRE 2 Series) IE is returning Javascript Errors, which are typically different from "Java" errors, as I understand it.

Dream
07-09-2005, 05:06 AM
right click on the page that give errors, view the source and paste it here, along with the javascript errors, then someone might be able to help

Cloudrunner
07-09-2005, 10:34 AM
right click on the page that give errors, view the source and paste it here, along with the javascript errors, then someone might be able to help
Also remember, that Firefox suppresses javascript errors so that they do not bug the users of the browser.

If you are doing coding work and using FF as a debugger then you'll need to extend it with something so that you can see the javascript errors if they happen. I use the extension Web Developer 0.9.3 in my FF. It gives a better idea of the javascript errors, and still suppresses the error pops, but notifies you in your toolbar via a red 'X' instead of a green checkmark. It has come in handy.

Another alternative that I have found is designed specifically for javascript debugging called Venkman, Mozilla's answer to the Javascript debugger that IE comes with. Can be found here: http://www.hacksrus.com/~ginda/venkman/

I just installed that extension, and am testing it now....

Andreas
07-09-2005, 07:41 PM
Erm ... you don't need an Extension on FF to view JS Errors, just click Extras/JavaScript-Console

Zachery
07-09-2005, 08:27 PM
FYI, don't forget the $headinclude template, very very important... (has all that js code that the browser is probally looking for).

Cloudrunner
07-09-2005, 08:34 PM
Erm ... you don't need an Extension on FF to view JS Errors, just click Extras/JavaScript-Console
really?

I didn't realize that as..thanks!

Kaelon
07-09-2005, 11:25 PM
Well, I found the problem. Apparently, it's looking for js files located at /root/clientscript/filename.js (when these files are actually located at /root/forums/clientscript/filename.js). Without writing my own $headinclude, is there any way I can correct this?

Thanks!

Andreas
07-09-2005, 11:28 PM
Symlinks

Kaelon
07-10-2005, 03:48 PM
Kirby - What do you mean by Symlinks?

I did fix the problem. Basically, I edited $headinclude to use absolute paths, rather than relative paths, to the javascript files. No more javascript errors. :)

Andreas
07-16-2005, 12:21 AM
Well, changing the Paths is also an Option. However, you must redo the changes if you must revert the Template.
Therefore Symlinks (Symbolic Links, eg. /foo/bar/file1.js pointing to /foo/bar/anotherdir/anotherfile.js at OS level) might be a better alternative :)