Setting top.someFrame.location...

H

hzgt9b

Using VS2005, VB.NET and lots of javascript,
I have a page with (gasp) frames on it. It has two frames a navigation
pane and a "content" pane. The navigation pane runs a page that has
lots of javascript in it. One of the scripts controls what is
dispalyed in the content pane. I am using the following code to
navigate the content pane to a url:

top.content.location=targetUrl;

This works great most of the time but sometimes I have trouble opening
pages with relative paths. How can I specify a path (i.e. targetUrl)
that always point to the same folder in my site?


PS - Frames: I am stuck with them for now - would love to get rid them
but I'm not in a position todo so right now - more discussion
regarding them is moot point regarding this post :)

Your thoughts appreciated.
 
S

SAM

hzgt9b a écrit :
Using VS2005, VB.NET and lots of javascript,
I have a page with (gasp) frames on it. It has two frames a navigation
pane and a "content" pane. The navigation pane runs a page that has
lots of javascript in it. One of the scripts controls what is
dispalyed in the content pane. I am using the following code to
navigate the content pane to a url:

top.content.location=targetUrl;

This works great most of the time but sometimes I have trouble opening
pages with relative paths. How can I specify a path (i.e. targetUrl)
that always point to the same folder in my site?

It is a simple html question ...

In the head of the menu's page (very close to top) :

<base href="mySite/myFolder/myPages/">

or if you want to send all pages in the same frame

<base href="mySite/myFolder/myPages/" target="content">

and your menu's links :

<a href="p1.htm">page 1</a>



About your JavaScript :

<a href="../../aPage.htm"
onclick="top.content.location=this.href;return false;">a page</a>
 
H

hzgt9b

hzgt9b a écrit :


It is a simple html question ...

In the head of the menu's page (very close to top) :

<base href="mySite/myFolder/myPages/">

or if you want to send all pages in the same frame

<base href="mySite/myFolder/myPages/" target="content">

and your menu's links :

<a href="p1.htm">page 1</a>

About your JavaScript :

<a href="../../aPage.htm"
onclick="top.content.location=this.href;return false;">a page</a>

Well, I don't actually have any links in the navigation pane itself -
its all java script logic. The only place the url exists is in the
java script "targetUrl".

Regardless, I need to know how java script sees the relative folders
in my site. Let me give you a little more detail on the problem I am
experiencing - I'll start by giving you a little tour of my site's
structure:

/
Default.aspx
Default.aspx.vb
web.config

/myApp1/
frame.aspx - defines the two frames: navigation (opens
navigation.aspx) & content (opens viewDocument.aspx)
viewDocument.aspx - page that is opened in the content pane -
this page accepts the targetUrl from the navigation query string
navigation.aspx - navigation frame - div onclick's trigger java
script to execute "top.content.location=targetUrl;"
NOTE: The targetUrl is always in the format:
"viewDocument.aspx?targetUrl=<some web page, local or on the web>"
where the page in the targetUrl string is always in the same folder as
navigation.aspx

/myApp1/localContent/

/myApp1/localContent/content1/
page1.html
page2.html, etc.

/myApp1/localContent/content1/page1_files/
page1Resource.htm
page1Resource.jpg
page1Resource.xml, etc.

/myApp1/localContent/content2/page2_files/
page2Resource.htm
page2Resource.jpg
page2Resource.xml, etc.



So, what happens is that my site opens to the frame.aspx page.
frame.aspx opens navigation.aspx in one frame and when the user clicks
on objects (DIV's) in the navigation page the following java script
runs to populate the content mane with data:

top.content.location=targetUrl;


The problem I am having is that when I click on my "page1" div,
targetUrl looks like this: "viewDocument.aspx?targetUrl=localContent/
content1/page1.html" but I get the following error:

The file '/myApp1/localContent/content1/page1_files/
viewDocument.aspx' does not exist.


The app is looking for viewDocument.aspx in the wrong folder... what I
don't understand is how the page and/or java script keeps track of the
current directory of the site. Can someone shed some light on this
subject and give me an explanation as to why I am getting the error
above?
 
H

hzgt9b

Well, I don't actually have any links in the navigation pane itself -
its all java script logic. The only place the url exists is in the
java script "targetUrl".

Regardless, I need to know how java script sees the relative folders
in my site. Let me give you a little more detail on the problem I am
experiencing - I'll start by giving you a little tour of my site's
structure:

   /
      Default.aspx
      Default.aspx.vb
      web.config

   /myApp1/
      frame.aspx - defines the two frames: navigation (opens
navigation.aspx) & content (opens viewDocument.aspx)
      viewDocument.aspx - page that is opened in the content pane -
this page accepts the targetUrl from the navigation query string
      navigation.aspx - navigation frame - div onclick's trigger java
script to execute "top.content.location=targetUrl;"
            NOTE: The targetUrl is always in the format:
"viewDocument.aspx?targetUrl=<some web page, local or on the web>"
where the page in the targetUrl string is always in the same folder as
navigation.aspx

   /myApp1/localContent/

   /myApp1/localContent/content1/
      page1.html
      page2.html, etc.

   /myApp1/localContent/content1/page1_files/
      page1Resource.htm
      page1Resource.jpg
      page1Resource.xml, etc.

   /myApp1/localContent/content2/page2_files/
      page2Resource.htm
      page2Resource.jpg
      page2Resource.xml, etc.

So, what happens is that my site opens to the frame.aspx page.
frame.aspx opens navigation.aspx in one frame and when the user clicks
on objects (DIV's) in the navigation page the following java script
runs to populate the content mane with data:

   top.content.location=targetUrl;

The problem I am having is that when I click on my "page1" div,
targetUrl looks like this: "viewDocument.aspx?targetUrl=localContent/
content1/page1.html" but I get the following error:

   The file '/myApp1/localContent/content1/page1_files/
viewDocument.aspx' does not exist.

The app is looking for viewDocument.aspx in the wrong folder... what I
don't understand is how the page and/or java script keeps track of the
current directory of the site. Can someone shed some light on this
subject and give me an explanation as to why I am getting the error
above?- Hide quoted text -

- Show quoted text -

Forgot to add this - I get they error above when navigating to page1,
but when I navigate to page2 everything works correctly (i.e. the web
app looks for viewDocument.aspx in the correct folder (i.e. '/myApp/')
 
H

hzgt9b

Forgot to add this - I get they error above when navigating to page1,
but when I navigate to page2 everything works correctly (i.e. the web
app looks for viewDocument.aspx in the correct folder (i.e. '/myApp/')- Hide quoted text -

- Show quoted text -

anyone?
 
T

Thomas 'PointedEars' Lahn

hzgt9b said:
Using VS2005, VB.NET
Irrelevant.

and lots of javascript, I have a page with (gasp) frames on it. It has
two frames a navigation pane and a "content" pane. The navigation pane
runs a page that has lots of javascript in it. One of the scripts
controls what is dispalyed in the content pane. I am using the following
code to navigate the content pane to a url:

top.content.location=targetUrl;

Should be

window.top.frames["content"].location = targetUrl;
This works great most of the time but sometimes I have trouble opening
pages with relative paths. How can I specify a path (i.e. targetUrl) that
always point to the same folder in my site?

Parse error.
[...] Your thoughts appreciated.

You should take heed of the FAQ, especially the part about proper
posting if you want to have any chance of helpful replies.

http://jibbering.com/faq/


PointedEars
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top