Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Markup (HTML, XHTML, XML) _ Referencing a js page

Posted by: arcticwanderer Jun 22 2007, 11:04 AM

Hello

This should be a simple thing but I can't get it right. If you look at the source on my website www.montagnaphotography.com I have a js code in the body that begins with the following:

<script>
/*****************************************************************************
Default browsercheck - Leave this one
******************************************************************************/
function lib_bwcheck(){ //Browsercheck (needed)
this.ver=navigator.appVersion; this.agent=navigator.userAgent .........</script>

The script works fine but is long and I want to cut it out of the body and put on a seperate page. I've cut it out, put it as a js.script file and tried referencing it using several codes such as: <script src="http://www.montagnaphotography.com/scripts.js" type=text/javascript></SCRIPT> without any luck. Does anyone have a suggestion how to reference the script correctly?

Posted by: Christian J Jun 22 2007, 04:07 PM

Could you provide a test page that shows the problem?

Posted by: pandy Jun 22 2007, 04:42 PM

Additionally, does your browser throw an error (turn debugging on if you haven't already)? Did you leave the script tags in when you copied the code to a separate file?

Posted by: Frederiek Jun 23 2007, 03:56 AM

An url was already provided: http://www.montagnaphotography.com

There is no javascript error, but the HTML does have errors when passing the page through the http://htmlhelp.com/tools/validator/. Some are related to the script element. Start by fixing those first.

For instance, you have:
<script language=JavaScript1.2 src="coolmenus3.js">">

The correct syntax is:
<script type="text/javascript" src="coolmenus3.js"></script>

(be sure to quote attribute properties, that goes for all attribute values in HTML tags too)

Other script elements in the page don't have a TYPE.

See the HTMLreference for the http://htmlhelp.com/reference/html40/special/script.html

You can link to the different scripts by adding as many such script elements to the page, eg. one for each functionality by copying the script in a text file, like you did for coolmenus3.js. Leave the legal comments together with the corresponding scripts. Then, if someone takes the code, the legal notice will be included with a reference to the original site of that script.

Posted by: pandy Jun 23 2007, 04:46 AM

QUOTE(Frederiek @ Jun 23 2007, 10:56 AM) *

An url was already provided: http://www.montagnaphotography.com

Christian tricked me. blush.gif

Posted by: Frederiek Jun 23 2007, 04:48 AM

Must be a swedish thing then biggrin.gif

Posted by: Christian J Jun 23 2007, 04:58 AM

QUOTE(Frederiek @ Jun 23 2007, 10:56 AM) *

An url was already provided: http://www.montagnaphotography.com

No, I meant a test page of the thing that didn't work. On the page above the script is still embedded.

Posted by: pandy Jun 23 2007, 05:18 AM

That wasn't clear. rolleyes.gif

QUOTE(Frederiek @ Jun 23 2007, 11:48 AM) *

Must be a swedish thing then biggrin.gif

I'm so gullible! blush.gif

Posted by: Frederiek Jun 23 2007, 06:00 AM

Christian, the OP did cut out the coolMenus script by Thomas Brattli (http://www.dhtmlcentral.com/coolmenus/). As I suggested, the same thing can be done for the other scripts taken from elsewhere too. Or it might be that the script doesn't work in a certain browser (which?). I didn't get any error in Safari.

Pandy, no harm done wink.gif

Posted by: Christian J Jun 23 2007, 08:06 AM

Now you're confusing me Fredriek, it's pandy that should be confused. tongue.gif

QUOTE(Frederiek @ Jun 23 2007, 01:00 PM) *

As I suggested, the same thing can be done for the other scripts taken from elsewhere too.

Agreed, but unless the OP shows an example of what didn't work we can't say what went wrong. The OP did post this example:

CODE
<script src="http://www.montagnaphotography.com/scripts.js" type=text/javascript></SCRIPT>

which looks OK to me.

Posted by: pandy Jun 23 2007, 09:07 AM

QUOTE(Christian J @ Jun 23 2007, 03:06 PM) *

Now you're confusing me Fredriek, it's pandy that should be confused. tongue.gif

Sometimes your mission fails. IPB Image

Posted by: arcticwanderer Jun 23 2007, 09:46 AM

QUOTE(Christian J @ Jun 22 2007, 04:07 PM) *

Could you provide a test page that shows the problem?


Here is a test page
www.montagnaphotography.com/baba. This will pull up the index to a folder I've called baba. As you can see the menu is gone. The scripts.js file is in the folder so it should work, but doesn't. You can look at that file by typing in : www.montagnaphotography.com/baba/scripts.js. The folder is a copy of the www.montagnaphotography.com/editorial page folder that has the js script still on the page and works fine. This tag : <script language=JavaScript1.2 src="coolmenus3.js"> works fine referencing the coolmenus3.js file so I don't understand why the other tag doesn't.

Thanks alot.

Posted by: Christian J Jun 23 2007, 12:13 PM

CODE
<script language=JavaScript1.2 src="coolmenus3.js">
<script language=JavaScript src="scripts.js">

These two need a closing </script> tag each.

Posted by: arcticwanderer Jun 24 2007, 08:57 AM

Thanks, that seems to do the trick. That's the problem with cutting and pasting, things get left out.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)