/    Sign up×
Community /Pin to ProfileBookmark

Trouble with Frames

Hi,
I’m a total newbie who is frustated with frames.
I want to link from one frame to another and send variables (php) along. The trouble is that the target frame is not always active meaning the frameset in which the target frame is in has to be loaded first.
So I got this tiny JavaScript that loads the desired frameset. I put an if statement in it so that the frameset is only loaded when needed.

[code=php]function change2frame(url)
{
if(window.top.main.location.href!=url)
{
window.top.main.location.href=url;
}
}[/code]

This does not work. The if statement is being ignored. I also tried if(!(window.top.main.location.href==url)). Same result.

I wouldn’t need this if all browsers would behave the same. The easiest thing would be to leave the “if” out and just have the window.top.main.location.href=url;. Put that in a “onClick” along with the link and it works. Only with Mozilla though. When using onFocus instead, it works on Opera, too. Still M$ Exploder and Safari evaluate the link first and then do the onFocus/onClick.

Please help.

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JAug 19.2004 — Why not call the function from the page in the target frame when it has loaded?
Copy linkTweet thisAlerts:
@kasparauthorAug 20.2004 — That would not work because the target frame is not available. It would load in a new window.
Copy linkTweet thisAlerts:
@Mr_JAug 20.2004 — So you are not loading into a frame within the frameset that is already open but into a frame in a newly opened frameset?
Copy linkTweet thisAlerts:
@kasparauthorAug 20.2004 — Yes.
Copy linkTweet thisAlerts:
@Mr_JAug 20.2004 — In the example in the zip I have created a frameset that has 2 frames.

In the document in the left frame a variable has been given a value.

Clicking the link in this document opens a second frameset that also has 2 frames.

When the page in the right frame of this second frameset has loaded it gets the variable value from the left page in the first frameset.

Am I correct in assuming this is something like what you are after?

[upl-file uuid=26ccdcee-799c-4624-b563-194f02affdc4 size=2kB]frame.zip[/upl-file]
Copy linkTweet thisAlerts:
@kasparauthorAug 20.2004 — This is nice. Thank you. For some odd reason it's not working in IE Mac and Safari. Mozilla and Opera are responding as described.
Copy linkTweet thisAlerts:
@Mr_JAug 20.2004 — Sorry but I only Have IE, Mozilla, and Firefox
×

Success!

Help @kaspar 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...