PDA

View Full Version : Help with linked in Javascript File



sfowler
12-20-2007, 06:29 PM
I have tried on multiple occasions to create and link in external .js files. It never works. Here is the latest attempt.

I would like to include the CalendarPopup.js from here. (http://www.mattkruse.com/javascript/calendarpopup/combined_source.html)

I saved the file into a subdirectory called "js".

I then tried to use this line to include it.


<script type="type/javascript" src="js/CalendarPopup.js"></script>

I also tried the same thing with language="JavaScript" instead of type="text/javascript" and it did not work either.

Is there something inherently wrong with the way I'm going about this? Or are there settings in IE and/or Firefox that do not allow this to work? Any help would be greatly appreciated.

TimFA
12-20-2007, 06:42 PM
Have you tried both type and language at the same time?

sfowler
12-20-2007, 06:55 PM
I just tried it that way, no go.

TimFA
12-20-2007, 07:05 PM
I just looked at the code, it appears you are mean't to separate it into a few different files. Date.js Anchor.js, etc. It says so in the code.

boogyman
12-20-2007, 07:17 PM
Have you tried both type and language at the same time?

the language attribute has been depreciated and should never be used

TimFA
12-20-2007, 07:45 PM
Either way it was worth a shot.

sfowler
12-20-2007, 07:55 PM
I didn't split the files. I saved the combined file version. Linked it in and tried to call the functions and objects from it and it hates me. Is there something wrong with the script tags that I used? Are there settings on Apache or in the browser that would stop this type of linking? I am at a complete loss.

TimFA
12-21-2007, 08:56 PM
I see nowhere is says it doesn't need to be seperated. Or atleast remove the text, I just skimmed it, but wasn't some of it not in comment tags?

Master_script_maker
12-21-2007, 09:58 PM
when you save an external .js file make sure you remove the
<script type="text/Javascript"></script> from the file

TimFA
12-21-2007, 10:53 PM
for (var i=0; i<checkList.length; i++) {
var l=window[checkList[i]];
for (var j=0; j<l.length; j++) {
d=getDateFromFormat(val,l[j]);
if (d!=0) { return new Date(d); }
}
}
return null;
}

/* SOURCE FILE: PopupWindow.js */

/*
PopupWindow.js
Author: Matt Kruse
Last modified: 02/16/04

DESCRIPTION: This object allows you to easily and quickly popup a window
in a certain place. The window can either be a DIV or a separate browser
window.

COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the
Macintosh platform. Due to bugs in Netscape 4.x, populating the popup
window with <STYLE> tags may cause errors.

USAGE:
// Create an object for a WINDOW popup
var win = new PopupWindow();

// Create an object for a DIV window using the DIV named 'mydiv'
var win = new PopupWindow('mydiv');

// Set the window to automatically hide itself when the user clicks
// anywhere else on the page except the popup
win.autoHide();



That is what I was referring to. If its not removed, it will not work. Unless I'm missing something...