/    Sign up×
Community /Pin to ProfileBookmark

Javascript Object Path

I am trying to get the current absolute object path of a frame. For example, I have a web page that has an iframe, but an additional iframe could open inside of that iframe. I am executing a top level function that would submit a form in the current iframe, so it would have to know whether I have loaded 2 iframes deep or 1 iframe deep to get to the currently loaded iframe. Hopefully this illustration will be helpful:

Page Page
| |
| or |
iFrame 1 iFrame 1
|
|
iFrame 2

I want to execute the same function at the page level to check a value in the current frame. I would like to set the path at the page level when frame 1 or frame 2 loads. Then, when you call the function at the page level, it would use the correct path to the variable I am looking for.

Thanks, – Greg

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@NedalsFeb 13.2005 — This maybe?
[size=1]
if (top.frame1_name) {
pagex = top.frame1_name.variable

} else if (top.frame1_name.frame2_name) {
pagex = top.frame1_name.frame2_name.variable
}
[/size]
Copy linkTweet thisAlerts:
@7studFeb 13.2005 — I don't think the second branch of that if statement would ever execute. I think you need to reverse the conditions. However, just because two iframes exist, it doesn't tell you which one is the 'current' iframe.

It's not clear to me what you want to do. Is the 'top' level function on the main page? What triggers its execution? If there is a 'current' iframe, then it seems to me something in that iframe must have triggered the event. In that case, you could pass the window object to the function, and the function would have a reference to the iframe that called it.
Copy linkTweet thisAlerts:
@Mr_JFeb 13.2005 — Try going on the number of frames

if(frames.length==1){

do_this

}

if(frames.length==2){

do_this

}


or

if(frames.length==1){

do_this

}

else{

do_this

}
Copy linkTweet thisAlerts:
@SiR_PiCkLEauthorFeb 14.2005 — I think what I am asking is similar to the app.path property in VB, but for a JavaScript frame. Using the app.path in VB, I am able to determine the absolute path to where the VB executable is. I was hoping there was a simialr property for a frame. I guess a better way to ask the question is to propose a challenge. Can you display a message in the currently loaded frame that gives me the path to the currently loaded frame? It should look like this:

The path of this frame is top.Frame1.Frame2

or

The path of this frame is top.Frame1

I would like to not have to maintain what is being loaded, but rather get the path through code, dynamically. So if I went three levels deep or branched off, I would still know what the current frame is. I hope this is clear.

Thanks for all of your replies, - Greg
×

Success!

Help @SiR_PiCkLE spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...