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 6998117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:22:13+00:00 2026-05-27T20:22:13+00:00

I have a session function that works well on the same domain, but when

  • 0

I have a session function that works well on the same domain, but when it is used through our api on another site, it doesn’t work because we are setting and calling from top frame (top.functionName, top.variable). What I am looking for is a way to set variables and call functions from the highest frame that still remains on the domain. For example, top frame might be externaldomain.com, frame within that might be ourdomain.com and frame within that might be ourdomain.com/somepage and so on. How would we loop through the frames to get the closest to the top that is still on the same domain?

Thanks,

  • 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-05-27T20:22:14+00:00Added an answer on May 27, 2026 at 8:22 pm

    The following function will return the closest frame. An error will be thrown if the frame is not at the same origin, because the document property cannot be read if the reader is from a different origin.

    Fiddle: http://jsfiddle.net/txmdL/3/
    JSfiddle runs on two domains: fiddle.jshell.net and jsfiddle.net. I have embedded multiple fiddle.jshell.net fiddles in the demo. If the script works as expected, clicking at the button will show a dialog containing http://fiddle.jshell.net/txmdL/3/show/

    function getClosestTop(){
        var frame = window;
        try {
            while (frame.parent.document !== frame.document) frame = frame.parent;
        } catch(e){}
        return frame;
    }
    

    The while loop will only break if:

    • The top has reached. top.document !== document will evaluate to false
    • The parent window is not at the same origin. An error will be thrown.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that works on a handful of servers, but not others which
I have a session class that needs to store session information in a MySQL
We have various related session variables for a complex page that has various things
I have a really simple chat application on a site which works pretty good.
I have some function (pasted below little piece of function), which I used as
I have the following function that I use to check a user login, at
I have this existing code which works very well. public static T SessionGet<T>(string key)
I am having a bizare problem where I have a script that works elsewhere
I have this login code, which works last night before I slept. Nobody used
I have a function that sets and unset's a $_SESSION variable depending on what

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.