468,301 Members | 1,477 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,301 developers. It's quick & easy.

Yet another Javascript and iframe question........

Hi everyone,

I am trying to create a site with pages containing iframes. This is the
first time I've used inline frames and am still struggling with the concept.

This site will have 10 pages and so far I have created 20 files, each page
having to use a pair of files. One file for the actual page, and one file
for the content of the inline frame.

It sounds bloody silly to me but then again I am only a beginner at web
devel. The tag I use for these pages look a bit like this:

<iframe name="frame" height="409" width="580" border="0" frameborder="0"
src="sub_contact.html" scrolling="auto"> Sorry, we're having
problems</iframe>

Is there any way I can use Javascript to detect what button/link has just
been clicked, and assign the appropriate value to the "src" variable? Then
perhaps I can only use one file for the actual page, and 10 files for each
content of the inline frames?

I hope this question makes some sense. I come from a programming background
but never web apps or anything remotely to do with dynamic web pages. Never
touched Javascript either!

Any suggestions or pointers (no puns intended) would be immensely
appreciated.

Cheers,
Dany.
Jul 20 '05 #1
3 3022


Dany P. Wu wrote:
I am trying to create a site with pages containing iframes. This is the
first time I've used inline frames and am still struggling with the concept.

This site will have 10 pages and so far I have created 20 files, each page
having to use a pair of files. One file for the actual page, and one file
for the content of the inline frame.

It sounds bloody silly to me but then again I am only a beginner at web
devel. The tag I use for these pages look a bit like this:

<iframe name="frame" height="409" width="580" border="0" frameborder="0"
src="sub_contact.html" scrolling="auto"> Sorry, we're having
problems</iframe>

Is there any way I can use Javascript to detect what button/link has just
been clicked, and assign the appropriate value to the "src" variable? Then
perhaps I can only use one file for the actual page, and 10 files for each
content of the inline frames?


Learn HTML, you can use a link with a target attribute set to the frame
name, thus if you have
<iframe name="iframeName"
then you use links alike
<a target="iframeName" href="whatever.html">
to load pages into the iframe. No need for JavaScript
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:3f********@olaf.komtel.net...

Learn HTML, you can use a link with a target attribute set to the frame
name, thus if you have
<iframe name="iframeName"
then you use links alike
<a target="iframeName" href="whatever.html">
to load pages into the iframe. No need for JavaScript


Hi Martin,

Thanks for the reply but that's not quite what I wanted. My apologies for
not explaining properly.

I realised you can create a link with an iframe as the target. What I was
after is a link on a particular page (page1), which loads another page
(page2) with the appropriate content displayed in an iframe in page2. The
content of the iframe on page two is dependent on the button clicked on
page1.

Is this possible?

Cheers,
Dany.
Jul 20 '05 #3
Dany P. Wu wrote:
What I was after is a link on a particular page (page1), which loads
another page (page2) with the appropriate content displayed in an iframe
in page2. The content of the iframe on page two is dependent on the
button clicked on page1.

Is this possible?


Unless you are not violating the Same Origin Policy, it is. All you need
is to follow the DOM tree down to the target IFrame object using the
frames[...] collection.
HTH

PointedEars
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by S'fly | last post: by
4 posts views Thread by PiedmontBiz | last post: by
8 posts views Thread by chrisdude911 | last post: by
6 posts views Thread by den 2005 | last post: by
16 posts views Thread by Phlip | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.