By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,974 Members | 1,913 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,974 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a


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

P: n/a
"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

P: n/a
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.