I have javascript on a page. The Page is set as the default to launch when the database is opened. The page opens , but the JS does not fire. However if I open the database referencing the page in the URL it does.
www.mysite.com\db.nsf - default page (PageOne) opens , no JS
www.mysite.com\db.nsf\PageOne?OpenPage - page opens, JS fires.
Any ideas on what’s going on?
Subject: JavaScript doesn’t fire
I figured part of it. I’m storing the JS as a file resource. If I include the database name in the JS reference on the page. It loads on the default dB open. However the mouseovers don’t work. And it doesn’t load when referenced as a complete URL
www.mysite.com\db.nsf\PageOne?OpenPage - page opens, now…no JS
Has to do with the relative URL’s obviously.
Subject: RE: JavaScript doesn’t fire
The problem is the URL to the JS file. When you open the page explicitly, the URL for the page is:
www.mysite.com\db.nsf\PageOne?OpenPage
If you are using a relative URL to the JS file (e.g., src=“myJavascript.js”), the browser looks for the file at:
www.mysite.com\db.nsf\myJavascript.js
When you open the database, and get the page by virtue of the database launch settings, the URL for the page is:
www.mysite.com\db.nsf
and the browser requests the javascript file from:
www.mysite.com\myJavascript.js
You’ll need to set a href to get both methods to work (unless you want to put the javascript into the JS Header object instead). To make it foolproof, it’ll mean using a Form instead of a page so you can use the Server_Name CGI field. Go to Jake Howlett’s site (http://www.codestore.net) and look for two articles:
“What to base your links on”:
http://www.codestore.net/store.nsf/unid/EPSD-52UQZJ?OpenDocument
and “Using a form as a database’s home page”:
http://www.codestore.net/store.nsf/unid/EPSD-4SWP67?OpenDocument
Subject: Thanks, I’ll check those out