".js" files cause Web Syntax Error

I have a horizontal menu on a web application, using JavaScript and Layers to work. I have put the necessary code into a subform which is placed at the top of the form. The “.js” files are stored as as “Shared Resources” element.

The code is:

This works great for the first form shown on the web - the Home Page - which is contained in a Frameset

However, I plug this subform into another form on the same website and 2 things happen:

  1. It does not appear

  2. “Syntax Error” - which I find the Notes Log as:

10/21/2003 07:37:30 AM HTTP Web Server: Lotus Notes Exception - Entry not found in index [/HR/ItemCntl.nsf/d3844d83d83b0f0988256a7800824b42/HVMenu_Custom.js]

10/21/2003 07:37:30 AM HTTP Web Server: Lotus Notes Exception - Entry not found in index [/HR/ItemCntl.nsf/d3844d83d83b0f0988256a7800824b42/HVMenu_Code.js]

When I look at the form containing that subform just by itself on the web, without the Frameset, everything works fine. When I view using the Frameset, it causes this error.

Am I missing something? I thought that this should work on any form because it looks for/loads the “.js” files?

Thanks!

Dan

Subject: “.js” files cause Web Syntax Error

Standard Web Error Number Two. There is a difference between the URL for a Design Element (Page, Form, Frameset, View) and a data document. All Design Notes are “peers” in the database. The URL for a Form looks like this:

http://server/path/database.nsf/FormName

The URL for your .js file looks like this:

http://server/path/database.nsf/filename.js

When the .js file is called using a relative URL by filename alone, it will be loaded properly since it appears to be in the same “directory”. Now, looking at a document:

http://server/path/database.nsf/ViewName/DocumentUNID

The .js file now appears to be in a higher-level “directory” than the document.

Go to http://www.codestore.net and search for an article entitled “What to base your links on”. It’ll give you a way to get rid of the problem.

Subject: RE: “.js” files cause Web Syntax Error

That makes sense - I didn’t even catch that…

Thanks for that!!!

I found the article (http://www.codestore.net/store.nsf/unid/EPSD-52UQZJ?OpenDocument) which got rid of the syntax error, however, the menu will not appear on the form either in the frameset or previewing itself in the browser…

Any ideas?

Thanks!

Dan

Subject: RE: “.js” files cause Web Syntax Error

I’d need a lot more info – JavaScript doesn’t fail locally unless you use try-catch-finally, so it’s an all-or-nothing proposition. Perhaps if you were to use something like Mozilla or Netscape 7 (which have built-in JavaScript debug consoles), or downloaded the Microsoft JScript debugger, you might get a better idea of what’s failing.

Subject: Some results & questions for “.js” files cause Web Syntax Error

Here is what I have done…

In the subform where the menu code resides there is some pass-thru HTML:

//

//

I place this subform at the top of the forms that the menu is needed.

The form that worked did not have the “DBPath” and “Server_Name” fields on it. DBPath is a computed for display field set to:

@ReplaceSubstring(@Subset(@DbName; -1); " " : “\”; “+” : “/”)”

Server_Name is a computed for display field that is set to itself: Server_Name.

The reason I used these fields is that I needed the “” tag to correctly find the two (2) .js files I needed for the menu to work correctly.

The tag was set in the HTML Head Content as:

“<base href="http://” + Server_Name + “/” + DBPath + “" />”

However, I even set the tag not to use variables and hard-coded the Server_Name and DBPath variables. The Menu would not appear, but the Syntax Error went away.

The settings above are from the article:

http://www.codestore.net/store.nsf/unid/EPSD-52UQZJ?OpenDocument

To get the Menu to work in every form correctly:

  1. Removed DBPath and Server_Name fields

  2. Set DBPath variable in HTML Head Content as:

DBPath := @ReplaceSubstring(@Subset(@DbName; -1); " " : “\”; “+” : “/”);

  1. Removed “” tag

  2. Through Domino Designer, I previewed in Internet Explorer and they all worked

The only problem is now, when the Menu is used through the Frameset, the Home Page works because that is where the .js files are. When I open another form, we are back to square one: The Menu causes a Syntax Error or does not appear because it cannot reference/find those .js files.

So here is the dilemma:

Why does the Menu not appear when the “” tag is referenced and then how do I reference the “.js” files for every document correctly if I cannot use the “” tag?

Thanks!

Dan

Subject: Revisit: Some results & questions for “.js” files cause Web Syntax Error

I hard-coded the whole URL into the “src=” value in the tag.

It worked for all forms in the frameset, however, only the graphics appeared in the home page.

The thing is, I just created a website that uses those two JavaScript files and did not have to use “” or hard-code anything.

I just plugged the subform in and it works perfectly.

No solutions, just headaches…

Subject: RE: Revisit: Some results & questions for “.js” files cause Web Syntax Error

Well, with stuff on a subform, the browser doesn’t have to request anything separately since the script is already on the web page. As for the “home page” – if you mean the thing you have set to open with the database URL (via the database launch properties), then you’re running into a base URL problem again. Let’s say you have a database at the Domino data root. When you open that database, you’re using a URL that looks like:

http://www.mycompany.com/database.nsf

If there are any relative URLs on the home page, they’ll be looking for your JavaScript file at:

http://www.mycompany.com/myscript.js

The simple cure for homepagitis is to redirect your users to:

http://www.mycompany.com/database.nsf/

It’s the trailing slash that makes the difference. Why are your images showing up? I’d guess that you created them either by using “Create>Image Resource” or pasted them in. In either case, Domino handles the relative URLs for you automagically.