jQuery Script not working when files are saved to Sub Directory

antzwebdesign

New Member
I am trying to save new pages into sub-directories, everything seems to be working properly, it links to my css and all my images perfectly, the only problem I am having is, the J query script for the Nav bar is not working when its in the sub-directory. If i take the same exact file and drop it back in the root it works %100.

You know how when you view a web page locally on your machine in IE and you get the message on the bottom of the screen saying -

"Internet Explorer Restricts this webpage from running scripts or ActiveX Controls and if you Do NOT click allow blocked content the top nav does not function properly, and no drop downs work/roll over properly." And how if you Do not click allow blocked content the nav bar on the top will not function properly and a few other things... Well this is exactly how my pages in the directory's are looking even after I hit allow block content.

The thing I don't understand is the script is linked like this <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> So I don't understand why putting it in a sub would matter, but it seems to matter and I cant figure out why.

Ive tested all my other code out and it seems to only be the above script that is messing it up, if I take that script out of pages in the root, I get the same problem I am having with the page in the sub.

Any help would be greatly appreciated, this is driving me crazy!
 

ronaldroe

Super Moderator
Staff member
I'm not sure I'm fully grasping what's going on here. Do you have another jQuery script you're trying to load, or some custom script within the HTML? I mean, you're not even calling jQuery from your server, so that has nothing to do with it. If you're dropping another script in a sub directory, there may be paths inside it that are dependent on a given directory structure. Or perhaps you aren't properly changing the src in your script tag. Regardless, we need more info.
 

antzwebdesign

New Member
I'm not sure I'm fully grasping what's going on here. Do you have another jQuery script you're trying to load, or some custom script within the HTML? I mean, you're not even calling jQuery from your server, so that has nothing to do with it. If you're dropping another script in a sub directory, there may be paths inside it that are dependent on a given directory structure. Or perhaps you aren't properly changing the src in your script tag. Regardless, we need more info.

Here is the code down to the main nav-

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="shortcut icon" href="../images/favicon.ico" />

<link href="../stylesheets/light/styles.css" rel="stylesheet" type="text/css" />

<title>Test | FAQ page</title>

<!-- Initialise jQuery Library -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript" src="../js/cufon/cufon-yui.js"></script>
</head>

And it seems like this script is the one that is giving me the problem with the navigation and a few other little things-

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
 

ronaldroe

Super Moderator
Staff member
So, which script are you trying to put in a different directory? You're calling jQuery from Google's CDN. I don't see anything there other than that, jQuery UI and Cufon.
 

antzwebdesign

New Member
So, which script are you trying to put in a different directory? You're calling jQuery from Google's CDN. I don't see anything there other than that, jQuery UI and Cufon.

Okay I will put the live URL below, you will see the nav bar working perfectly and everything is good. Now if you go back up to blog on that same page and click the grey box in the nav that says blog (not the drop down ) it will take you to the same exact page that is saved in the directory, and if you look at the code you will be everything pointing to the correct place, but the nav bar will not work.

Here is the working page, and click the blog again for the directory page - http://www.longislandwebsitedesign.biz/blog_alternate.html
 

antzwebdesign

New Member
Use root relative URIs, that way URIs will always be the same no matter where the document is in the website structure.

Thanks for the advice, unfortunately that did not seem to help.
I believe the problem I am having is with this absolute link - <script type="text/javascript" src="/http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>

When I take that out of the files in the root, I get the same problems as the files I save into the sub directory's, and I don't understand why if its an absolute link.

Were you able to take a look at the link I left in the last post, and see the way the site looks on the blog page, and if you click blog again, the way the nav changes?
 

chrishirst

Well-Known Member
Staff member
That is an absolute URL and should NOT have a forward slash.

It is relative URIs that should be root relative eg: path/path/file.ext or ../path ESPECIALLY the ../ ones because the ../path convention 'says' "in a folder called 'path' ABOVE the current folder, so if you are in the root folder ../ has no meaning as browsers are NOT allowed access above the root so it will "break"
 

antzwebdesign

New Member
That is an absolute URL and should NOT have a forward slash.

It is relative URIs that should be root relative eg: path/path/file.ext or ../path ESPECIALLY the ../ ones because the ../path convention 'says' "in a folder called 'path' ABOVE the current folder, so if you are in the root folder ../ has no meaning as browsers are NOT allowed access above the root so it will "break"

I am like 99% its the file below that is messing up my nav, how should i rewrite it to get it to work properly in my sub directory?

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
 

ronaldroe

Super Moderator
Staff member
I am like 99% its the file below that is messing up my nav, how should i rewrite it to get it to work properly in my sub directory?

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>

What we're trying to tell you is that this line of code is calling a file that's not even on your server, and whatever you're "putting in a sub directory" is something else. If you can let us know what that is, we can help.

EDIT: I looked around in your code. On all the other pages, you're calling jQuery as above, but for some reason call it from your own server on the page where it doesn't work. Make it like the code above on every page.
 
Last edited:

chrishirst

Well-Known Member
Staff member
I am like 99% its the file below that is messing up my nav, how should i rewrite it to get it to work properly in my sub directory?

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>

Well, the other 1% of you is the bit that has it correct, as absolute URLs are the same no matter where they are in the folder structure (physical or virtual).

That is why they are called absolute, because the location they point to is always the same.
 
Top