integrating JS files into theme?

Mar 4, 2010 at 4:00 PM

Hi All: I created a custom theme based on the "standard" theme, for BE 1.6 running as a sub-application in a parent website.

The parent website uses the opensource "nifty corners cube" JS to create rounded corners on CSS elements like divs. On the parent site, the code runs fine with no errors. When creating the theme, I copied the JS and related CSS files into the theme folder, and linked them into the theme's master page:

 

    <script src="corners.js" type="text/javascript"></script>
    <link href="corners.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    NiftyLoad=function(){
        corners("ul.newNavBut a", "transparent small");
    }
</script>

<script src="corners.js" type="text/javascript"></script>

<link href="corners.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

    NiftyLoad=function(){  corners("ul.nav a", "transparent small");    }

</script>

When I load any blog page, IE's debugger throws an error: 
Message: Syntax error
Line: 3
Char: 1
Code: 0
URI: http://mysite.com/blog/post/2009/04/25/corners.js
but this is the same exact code that runs fine elsewhere on the website. That line in the JS file is:
String.prototype.find = function(what) {
What would be causing this error? A conflict with other JS code that BE is loading? Or am I targeting the JS file incorrectly?

 

Mar 4, 2010 at 7:28 PM

Try another debugger ( like firefox maybe ).  It might give you a better error message - there doesn't seem to be anything particularly wrong w/ that line... it might be the line above it.

Mar 5, 2010 at 3:20 PM

In your themes site.master file try the following:

Change

From: <script src="corners.js" type="text/javascript"></script>

To: <script src="js.axd?path=corners.js" type="text/javascript"></script>

 

 

Also note that in the error message the 'corners.js' path is located in your post path (URI: http://mysite.com/blog/post/2009/04/25/corners.js) - which is not the location of your js file I'm assuming. By using  blog engines javascript handler, it should remedy that - just make sure the path points to the relative path based on the root (not your themes folder).