Setting top.someFrame.location...

Discussion in 'Javascript' started by hzgt9b, Feb 14, 2008.

  1. hzgt9b

    hzgt9b Guest

    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.
     
    hzgt9b, Feb 14, 2008
    #1
    1. Advertising

  2. hzgt9b

    SAM Guest

    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>


    --
    sm
     
    SAM, Feb 14, 2008
    #2
    1. Advertising

  3. hzgt9b

    hzgt9b Guest

    On Feb 14, 6:58 pm, SAM <>
    wrote:
    > hzgt9b a écrit :
    >
    > > Using VS2005, VB.NET and lots of java script,
    > > 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 java script 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>
    >
    > --
    > sm


    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?
     
    hzgt9b, Feb 15, 2008
    #3
  4. hzgt9b

    hzgt9b Guest

    On Feb 15, 10:23 am, hzgt9b <> wrote:
    > On Feb 14, 6:58 pm, SAM <>
    > wrote:
    >
    >
    >
    >
    >
    > > hzgt9b a écrit :

    >
    > > > Using VS2005, VB.NET and lots of java script,
    > > > 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 java script 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>

    >
    > > --
    > > sm

    >
    > 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/')
     
    hzgt9b, Feb 15, 2008
    #4
  5. hzgt9b

    hzgt9b Guest

    On Feb 15, 10:40 am, hzgt9b <> wrote:
    > On Feb 15, 10:23 am, hzgt9b <> wrote:
    >
    >
    >
    >
    >
    > > On Feb 14, 6:58 pm, SAM <>
    > > wrote:

    >
    > > > hzgt9b a écrit :

    >
    > > > > Using VS2005, VB.NET and lots of java script,
    > > > > 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 java script 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>

    >
    > > > --
    > > > sm

    >
    > > 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/')- Hide quoted text -
    >
    > - Show quoted text -


    anyone?
     
    hzgt9b, Feb 16, 2008
    #5
  6. hzgt9b wrote:
    > 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
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
     
    Thomas 'PointedEars' Lahn, Feb 17, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frederic HOUDE
    Replies:
    4
    Views:
    622
    Frederic HOUDE
    Aug 31, 2004
  2. Vince Morgan

    DOM window.top.location

    Vince Morgan, Nov 11, 2006, in forum: HTML
    Replies:
    6
    Views:
    1,689
    Neredbojias
    Nov 16, 2006
  3. Cuthbert
    Replies:
    8
    Views:
    454
    Ancient_Hacker
    Sep 13, 2006
  4. AAaron123
    Replies:
    6
    Views:
    606
    AAaron123
    Nov 5, 2009
  5. find clausen

    window.opener.top.location.top.close ???

    find clausen, Oct 5, 2003, in forum: Javascript
    Replies:
    2
    Views:
    451
    find clausen
    Oct 5, 2003
Loading...

Share This Page