Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7843163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:29:13+00:00 2026-06-02T16:29:13+00:00

The problem In my application I have a parent page which contains an iframe

  • 0

The problem

In my application I have a parent page which contains an iframe to a child page in a subdirectory.

parent.html
subdir/child.html

From within the child page, I would like to set the location of the parent page using a relative url (“targetPage.html”), relative to the parent.

parent.html
targetPage.html (correct target)
subdir/child.html (source of action)
subdir/targetPage.html (incorrect)

From within the child, I can say:

window.parent.location = "targetPage.html";

…but of course, that (incorrectly) navigates the parent page to “subdir/targetPage.html”, because the code is running in the context of the child.

Calling code in the parent doesn’t help:

window.parent.myFunctionToNavigateToTarget(); // defined in parent to navigate to "targetPage.html"

… has the same effect, as the parent’s function is being run in the context of the child.

The Question

Is there an elegant way to set the location of another window using a relative URL, in such a way that it’s interpretted relative to that window?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:29:13+00:00Added an answer on June 2, 2026 at 4:29 pm

    You could grab the hostname and path off the parent window and then append your target page:

    var targetPage = 'somepage.html';
    
    var url = window.parent.location.href;
    if(url.indexOf('.') > -1){
       url = url.substring(0, url.lastIndexOf('/') + 1);
    }
    window.parent.location = url + targetPage;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a single page jquery mobile application in which there are few parent
The problem: we have one application that has a portion which is used by
I have a parent contentcontrol which displays data via a datatemplate. The datatemplate contains
I'm trying to access the URL of a SharePoint page from within an iframe.
I have two pages, the parent and from this page I am using: window.open('OrderDetailsFull.aspx?ObjectID='
I am developing an xbap application and have run into a problem with users
My problem is to find best view configuration for my application that have a
I won't create wallpaper-application but have one problem. Please tell me how add ImageView
I have problem with my application. I have table report, there are 2 column
I have a problem linking an application for an embedded target. I'm developing on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.