The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> iFrames
liDev
post Apr 28 2009, 11:29 AM
Post #1





Group: Members
Posts: 4
Joined: 15-April 09
Member No.: 8,335



Hi All. I'm working on a test page as a proof of concept to see if something works. I have an HTML page (Page1.html) with a button that calls a javascript function to grab the URL address of the web browser and display it in an alert box. That works fine.

In my HTML page I then introduce an inline frame tag <iFrame> that calls Page2.html. From Page2.html can I call the javascript function from Page1.html? Or from Page2.html is there a javascript function I can write to grab the URL address of Page1.html (the parent frame/page)?

Any advice would be greatly appreciated. Thanks in advance!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Apr 28 2009, 12:39 PM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



This is about Client-side Scripting, so I moved it to the appropriate forum.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Apr 28 2009, 06:14 PM
Post #3


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



You refer to a frame's parent window with 'parent'. 'top' always refers to the topmost window (in the case of nested frames). So in this case either would do.

CODE
parent.location.href

CODE
top.location.href
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
liDev
post Apr 29 2009, 09:23 AM
Post #4





Group: Members
Posts: 4
Joined: 15-April 09
Member No.: 8,335



QUOTE(pandy @ Apr 28 2009, 07:14 PM) *

You refer to a frame's parent window with 'parent'. 'top' always refers to the topmost window (in the case of nested frames). So in this case either would do.

CODE
parent.location.href

CODE
top.location.href



Thanks Pandy that does work.

I do have another question: Continuing with the use of in line frames, is it possible to have a link outside the <iFrame> page tag cause the content within the iFrame object to change to another page? Meaning, I basically have an HTML page with a bunch of links (ex cnn.com, espn.com, etc...) and underneath these menu links I have the <iFrame> tag defaulted to cnn.com. Now if I click on espn.com can it switch the iFrame content from cnn to espn? I know this can be done with traditional frames/framesets but can this be done with inline frames?

Thanks for your help and advice!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
liDev
post Apr 29 2009, 09:36 AM
Post #5





Group: Members
Posts: 4
Joined: 15-April 09
Member No.: 8,335



Never mind I figured it out. For those who don't kow...

1) Give the iFrame a name/identifier. Ex: <iFrame name="tgt_Page" src="http://www.mlsnet.com">
2) Reference the iFrame name in the TARGET parameter of the <A> Tag. EX: <A HREF="http://www.nyredbulls.com" TARGET="tgt_Page">

Thanks!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th March 2024 - 10:27 PM