javascript, frames and relative path problem...

H

hzgt9b

I have a page with frames on it. (I am stuck with them for now - would
love to get rid them but I'm not in a position to do so right now -
more discussion regarding them is moot point regarding this post.)
Here's the folder layout of the site, with some example files listed:

/myApp1/frame.aspx - main page that opens after user is
authenticated to the site. It defines two frames: navigation (opens
navigation.aspx) & content (opens viewDocument.aspx)
/myApp1/viewDocument.aspx - page that is opened in the content
frame - this page accepts a targetUrl from the "navigation" frame via
a query string
/myApp1/navigation.aspx - user actions trigger java script to
execute "top.content.location=targetUrl;" NOTE: The targetUrl is
always in the format: "viewDocument.aspx?targetUrl=<some page with
path relative to /myApp1/ folder>"
/myApp1/localContent/
/myApp1/localContent/someFolder/page1.html
/myApp1/localContent/someFolder/page1_files/page1Resource.htm
/myApp1/localContent/someFolder/page1_files/page1Resource.jpg
/myApp1/localContent/someFolder/page1_files/page1Resource.xml,
etc.
/myApp1/localContent/someFolder/page2.html, etc.
/myApp1/localContent/someFolder/page2_files/page2Resource.htm
/myApp1/localContent/someFolder/page2_files/page2Resource.jpg
/myApp1/localContent/someFolder/page2_files/page2Resource.xml,
etc.


As noted above, the main page has two frames: a "navigation" frame and
a "content" frame. The "navigation" frame runs a page displaying a
list of pages - this page has lots of java script in it to handle
clicks on HTML DIV elements (i.e. not <a> based links). When one of
these DIV objects gets clicked its onclick event handler attempts to
set the location of the "content" frame using something like the
following script:

top.content.location="viewDocument.aspx?targetUrl=localContent/
someFolder/page1.html"
(notice the relative path in the targetUrl)


The page in the targetUrl is always viewDocument.aspx (which is in the
same folder as the page that defines the frames, frame.aspx). The
query string always directs viewDocument.aspx to open some other page
or object (query string information comes from a database) inside an
iframe object on the viewDocument.aspx page (which inside the
"content" frame). Thus far, everything is working well except one
thing - making java script calls from the page opened inside the
iframe (i.e. page1.html). On some action (button click, keydown, etc.)
the page opened in the iframe will attempt to call a java script
function in the "navigation" frame to load the next page like this:

top.navigation.nextPage();


This function, running in the "navigation" frame, does a few house
keeping items then eventually makes the call to change the "content"
frame's location to the new targetUrl. So, assuming page1.html is
currently displayed in the "content" frame, the following java script
would be executed

top.content.location="viewDocument.aspx?targetUrl=localContent/
someFolder/page2.html"


But the page never loads because "viewDocument.aspx" cannot be found.
Here's the error message that I am receiving:

The file '/myApp1/localContent/someFolder/page2_files/
viewDocument.aspx' does not exist.


So, it appears that the site's relative path is has changed to the
path of the page inside the "content" frame's iframe. The application
should be looking for viewDocument.aspx in the "/myApp1/" folder
instead of in some sub folder to the localContent folder. The really
curious thing is that the relative path in not always wrong - on some
calls to nextPage() from the iframe, viewDocument.aspx is found and
runs without incident. I'm really baffelled by this.


QUESTIONS:
- What caused the relative path to change?
- Is there are way for me to check the relative path of the currently
executing script so that I can react to it before attempting to
navigate to a page?
- without using baseurl or absolute path's (site maintains its
session in the url) is there a way for me to specify the correct path
dynamically?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top