Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to chage documents in two different frames w/ one hyperlink 1

Status
Not open for further replies.

finchmama

Technical User
Jan 28, 2003
2
US
Alright, this is kind of a long one, but I've included some troubleshooting of my own that will hopefully help anyone wanting to takcle this problem.

Here's the deal: I've got a website index page (index.html) that is split up into 3 frames:

name: Frames (name given to the index page when it loads)
Code:
<frameset rows=&quot;110px,*&quot; frameborder=&quot;0&quot; border=&quot;0&quot;>
    <frame src=&quot;HomePageTitle.html&quot; scrolling=&quot;no&quot; name=&quot;Title&quot;>
    <frameset cols=&quot;20%,*&quot; frameborder=&quot;0&quot; border=&quot;0&quot;>
	    <frame src=&quot;LeftMargin.html&quot; scrolling=&quot;no&quot;>
	    <frame src=&quot;HomeMenu.html&quot; scrolling=&quot;yes&quot; name=&quot;Home&quot;>
    </frameset>
    <noframes>	If you see this message, then your browser doesn't support frames, which are required to
	view this page.
    </noframes>
</frameset>

I've also got a popup window that the HOME page creates in the onLoad event handler called UPDATES. Here's the problem: I'm trying to change the documents of two different pages, HOME and TITLE, w/ one hyperlink located in UPDATES. I've had no problems being able to change either HOME or TITLE via a link within UPDATES as long as I set &quot;HOME&quot; or &quot;TITLE&quot; as the target for the hyperlink. However, whenever I try setting the target to, we'll say, TITLE, then try using the onClick event to change the HOME page, it gives me an error. Below are some examples of variations I've tried and the errors it gave me:

EXAMPLE 1:
Code:
<a href=&quot;BandPicsTitle.html&quot; target=&quot;Title&quot; onClick=&quot;Home.location.href='ByLocation.html'; return true;&quot;>pics and movies</a>

ERROR:
'Home' is undefined


EXAMPLE 2:
Code:
<a href=&quot;BandPicsTitle.html&quot; target=&quot;Title&quot; onClick=&quot;parent.location.href='ByLocation.html'; 
return true;&quot;>pics and movies</a>

ERROR:
no error; however, it loads the 'ByLocation.html' in the UPDATES window for some reason (&quot;parent&quot; isn't the same thing as &quot;self&quot; is it? [ponder])


EXAMPLE 3:
Code:
<a href=&quot;BandPicsTitle.html&quot; target=&quot;Title&quot; onClick=&quot;parent.parent.location.href='ByLocation.html'; return true;&quot;>pics and movies</a>

ERROR:
no error; again, it loads the 'ByLocation.html' in UPDATES


EXAMPLE 4:
Code:
<a href=&quot;BandPicsTitle.html&quot; target=&quot;Title&quot; onClick=&quot;Frames.Home.location.href='ByLocation.html'; return true;&quot;>pics and movies</a>

ERROR:
'Frames' is undefined

In all the above examples, the page was sent to the TITLE page fine. Also worth noting, I've got a link within the HOME page itself that does the same thing I'm trying to do from the UPDATES page, only it works :D The code for that looks like this:

Code:
<a href=&quot;BandPicsTitle.html&quot; target=&quot;Title&quot; onClick=&quot;parent.Home.location.href='ByLocation.html'; return true;&quot;>pics and movies</a>

For some reason, when the hyperlink is located within the frames themselves, it has no problem resolving the code within the onClick event. *scratches head*

If anyone could give me some advice on this problem, I'd greatly appreciate it. Thanks in advance!!
 
I spent a little time at this and then realised I was being thick...%-) >:-<

Got there in the end though.

call a quick script from the href:

<a href=&quot;#&quot; onClick=&quot;Javascript:eek:penup()&quot;>pics and movies</a>

and make the script read:

function openup()
{
opener.location='BandPicsTitle.html'; //the frame that opened the pop-up - Home
opener.parent.frames[0].location='BandPicsTitle.html'; //the frame indexed at 0 from the opener's parent - Title
}

this seems to work for me...
[rednose]
 
You're a genious, coxellis! Your solution worked like a charm, thanx alot for taking the time to answer my thread [thumbsup]

If I may indulge you once more (or anyone else who sees this thread and chooses to answer), so that I can learn and not just do as I'm told, I was wondering if you could clear a few things up for me:

1. From you code and the code I've seen elsewhere, am I right in assuming that &quot;opener&quot; is a generic object reference, just like &quot;parent&quot; or &quot;self&quot; or &quot;this&quot;?

2. Are all pop-up windows children of the window that called them? Or is the relationship more &quot;the caller&quot; and &quot;the called&quot;?

3. Is there a generic term for the called window that the caller window can use, or should it just assign a name at the time the window is created and use that name to reference it?

4. How come when I used &quot;parent.location&quot;, the Updates window targeted itself instead of the window that called it, or giving an error?

5. How come when I used the names of the windows (i.e. &quot;Home&quot; and &quot;Frames&quot;) that it gave an error saying &quot;undefined&quot;? Is there a way for any pop-up window to reference a window by name w/o using &quot;opener&quot; or w/o having to specifically set that name in the
Code:
TARGET
attribute of the
Code:
<A>
tag?

Again, I realize this is alot to have to answer, but any further help would be just as appreciated as what you've already done. Kudos to you again, thanx!
 
In answer, I should make the following point. I'm self-taught and don't know a lot of the correct jargon, or, for that matter, the answer. But,

1. opener can be any object that can call an href. Yes.

2. unless the window calling the pop-up has a name, it's only identifier is opener or opener.parent if using frames. The parent is often taken as meaning the current document's window.

3. You can say
indexaddress = opener.parent;
at the outset and use the object container 'indexaddress'. If there's a generic name for this, I don't know it.

4. From 2, this defines the current documents window as 'parent'

5. You have to give the current window that runs as a separate instance of the browser, a term of relation to the other window. In this case, I don't know of any other reference.

to explain:

function openup()
{
opener.location='BandPicsTitle.html'; //the frame that opened the pop-up - Home re-assign the url of the frame theat opened the pop-up

opener.parent.frames[0].location='BandPicsTitle.html'; //the frame indexed at 0 from the opener's parent - Title Your title bar is referenced by calling the opener's parent window and looking at the first frame in the default array, frames (0 being the first entry in the array set by the loaded index page)
}
Does this make it worse or better?

Andy
:-D


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top