Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2004, 10:57 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

twinkle,

try replacing right.src with document.getElementById('right').src

HTH,

----------
---Snib---
----------

<><
 
Old March 17th, 2004, 11:04 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Snib,

I am afraid that won't work.

The right frame doesn't live in the same page. Both Left and Right are loaded in separate frames. To reach the frame, you'll need to access it through its parent property.

On Page 1 of this thread, I showed Twinkle how to do this (parent.leftFrame.document.getElementById('imgTest ').src) and suggested the alternative to set the source for the iframe directly (parent.leftFrame.src)

However, it looks like Twinkle is after something else.

Twinkle: want to give us a status update about what you have so far, and where you want to go?

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 17th, 2004, 11:42 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Code:
index.html

<iframe src=left.html /><iframe id=right src=right.html />

left.html

<img src=imageone.png onclick="parent.document.getElementById('right').src=this.src">
<img src=imagetwo.png onclick="parent.document.getElementById('right').src=this.src">

right.html doesn't need anything in it.
Would this work?

I would try it on my own, but my server is being upgraded so I can't use it right now...

----------
---Snib---
----------

<><
 
Old March 17th, 2004, 12:02 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, that would definitely work.

However, right from the beginning, these kind of solutions have been offered. I tried to explain the general idea, without too much of an example, Joe posted a working example, you threw some useful stuff in the mix, but apparently, it's not what Twinkle is after.

I think what's he/she is after is a more advanced example. What we are offering here, is just a simple "find and replace": Find the target's source, and replace it with another image.
What is really needed is some more advanced stuff using z-indices, positioning and other JavaScript tricks to "dress the doll".

The Madonna link (or the Hanson link, if you can stand them) provides some more background information, but I am not sure whether that was enough or not.


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 31st, 2004, 06:06 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

Quote:
quote:Originally posted by twinkle
 Hi,
I need to know that: if u have a page with 2 iframes, one containes pictures and the other one is empty -
now if i want those pictures to appear in the empty iframe how to i do that?????

plz help!
1) First of all give name to your frames in FRAMESET.
   e.g, <FRAME name="./main" href="./main_page1.htm">
2) Just target other files to main frame from side frame.
   e.g., <A href="./main_page2.htm" target="./main"><IMG tag here></A>

That's all ..keep going!







Similar Threads
Thread Thread Starter Forum Replies Last Post
Frames Simmy73 ASP.NET 2.0 Basics 1 May 26th, 2006 07:26 AM
Frames ricardo_s HTML Code Clinic 1 April 27th, 2006 02:37 PM
FRAMES twinkle Javascript 2 March 30th, 2004 02:04 AM
i frames and all that Adam H-W HTML Code Clinic 2 November 5th, 2003 12:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.