There is probably something I don't understand about using Javascript in Umbraco...
I thought I would keep things nice and tidy so I created a .js file under Settings/Scripts in the backoffice. Added my tiny little JS-code, included the file using <SCRIPT...>-tags in the template and tried it. Immediately got an fairly unspecified error that I know is typical when the .js-file cant be found.
In the backoffice I can see the URL of my JS-file (/scripts/myFile.js). Tried to browse to that URL but I get a 404 error. I then created copy of the file in the document tree root, changed URL in my <SCRIPT...>-block and now it all works!
Is the Scripts section not to be used like this or what?
Stephen, That is exactly what happens. I follow the link and get a 404 in return. How can the file be "not formed correctly"? I just created a silly test function like this:
function test() { alert("Hello"); return(false); }
Should there be some kind of header info in there as well? Still, that should not give me a 404, should it? And shouldn't the file actually be visible in the file system under /scripts? Right now it isn't.
Nah no header info needed in the file...what you are trying to do should work (i just done it on my install) have you checked your security settings on the folder? Also is your install setup as a virtual directry?
Javascript file not found
There is probably something I don't understand about using Javascript in Umbraco...
I thought I would keep things nice and tidy so I created a .js file under Settings/Scripts in the backoffice. Added my tiny little JS-code, included the file using <SCRIPT...>-tags in the template and tried it. Immediately got an fairly unspecified error that I know is typical when the .js-file cant be found.
In the backoffice I can see the URL of my JS-file (/scripts/myFile.js). Tried to browse to that URL but I get a 404 error. I then created copy of the file in the document tree root, changed URL in my <SCRIPT...>-block and now it all works!
Is the Scripts section not to be used like this or what?
Hey Jonas,
When you view a script file in Umbraco there is a link to view just below the name of the file...did you get a 404 error when clicking on that?
Can only think the JS file was not formed correctly as this should work as you expect it to.
S
Stephen,
That is exactly what happens. I follow the link and get a 404 in return. How can the file be "not formed correctly"? I just created a silly test function like this:
function test()
{
alert("Hello");
return(false);
}
Should there be some kind of header info in there as well? Still, that should not give me a 404, should it? And shouldn't the file actually be visible in the file system under /scripts? Right now it isn't.
/Jonas
Nah no header info needed in the file...what you are trying to do should work (i just done it on my install) have you checked your security settings on the folder? Also is your install setup as a virtual directry?
S
Hi. Actually it shouldn't be required, but just for test try to add ~/scripts/ to your umbracoReservedPaths application setting.
Oh, and another question - is that sort of a "pure" 404 or a "page intentionally left ugly"?
is working on a reply...