Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 15th, 2004, 04:06 PM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default frames

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!

Reply With Quote
  #2 (permalink)  
Old March 15th, 2004, 04:35 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Can you please not triple (or double) post your messages here? Your message will be read anyway.

That said, can you explain your situation in some more detail? It's not really clear what your requirements are.

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old March 15th, 2004, 04:44 PM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

sorry 4 that .....wasnt sure where i was supposed to post the topic

well i created a site that delas with iframes

the site containes 2 iframe: one that containes pictures(right.html) and the other one is empty (left.html)

i want the user to be able to click on a pic from the iframe that contains pictures n then the selected picture to appear in the empty iframe (left.html)


this is my problem, cant make it work- tried a few codes!
hope u can help me

Reply With Quote
  #4 (permalink)  
Old March 15th, 2004, 05:30 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

What code did you use so far?

I think if you give each image in the right frame an ID, you could try something like this:

leftFrame.src = rightFrame.document.getElementById('imageID').src;

This retrieves the src property for the select image and then uses that to fill the src property for the left frame, overwriting its current value of Left.html.

I haven't tested this, but I think it should get you in the right direction....

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #5 (permalink)  
Old March 15th, 2004, 05:46 PM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default




the main site contains:

<IFRAME src="left.html" name=leftFrame align="center" width="320" height="370" frameborder="0" scrolling="yes">
If you can see this, your browser does not support iframes! Please consider upgrading your browser to IE 5x or Netscape 6.
</IFRAME>


<IFRAME src="right.html" name=rightFrame align="center" width="320" height="370" frameborder="0" scrolling="yes">
If you can see this, your browser does not support iframes! Please consider upgrading your browser to IE 5x or Netscape 6.
</IFRAME>

the right.html contains:


window.onload=alertFrame
function alertFrame(){
alert(frames["leftFrame"].name)
}

<a href="#" onclick="parent.leftFrame.img.src="Picz/image2.jpg">
<img src="Picz/image2.jpg" width="60" height="70" />


the left.html is empty




Reply With Quote
  #6 (permalink)  
Old March 15th, 2004, 06:47 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

FYI, take a look here: http://p2p.wrox.com/topic.asp?TOPIC_ID=7305

----------
---Snib---
----------
Reply With Quote
  #7 (permalink)  
Old March 15th, 2004, 06:53 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

There are a few issues with your code.

First of all, it's easiest if Left.html is not empty, but holds an existing <img> tag with an ID, like I proposed in a previous message. Otherwise, you'll need to use document.write statements to write out the image tag to the left frame. You could avoid this latter situation by setting the src of the frame to the new URL, instead of setting the src of the image inside the frame.

So, add the following code to the left frame:

<img src="spacer.gif" id="imgTest" /> where spacer,gif points to an existing spacer image. Notice the ID attribute: we need this later to change the src of the image.

The next thing you need to fix is the way you address the document in the frame. The leftFrame doesn't expose its inner objects directly; you'll need to get to them through the document object. Once you are at the document, you can use collections like images, or use getElementById to get at a single element. Change the code for the <a> tag to this:

<a href="#" onclick="parent.leftFrame.document.getElementById( 'imgTest').src='NewImage.gif';">Contents for A tag go here</a>

The final thing I changed is your quotes usage in the onclick attribute. You're incorrectly using the double quotes to enclose the new value for the src attribute. In your case, it tries to close the onclick attribute, rather than opening the value for the src attribute. Confusing, I know, but using an apostrophe to enclose the new name of the image does the trick, as in the code above.

One final note: this example assumes it's OK for Left.html to contain an initial image, even if that is just a 1x1 spacer image. If that is not appropriate, you'll need to use document.write to create an entirely new document in the left frame, or you could set the src attribute of that frame to the new image name.

Does this help?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #8 (permalink)  
Old March 15th, 2004, 07:14 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Oops, how did I miss this?

right.html has javascript outside of <script> tags!

----------
---Snib---
----------
Reply With Quote
  #9 (permalink)  
Old March 15th, 2004, 07:22 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
quote:right.html has javascript outside of <script> tags!
Right, didn't really see that either. It looks like a debugging function to me, so it really shouldn't matter. Otherwise, indeed enclose the code in <script> tags.....

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #10 (permalink)  
Old March 16th, 2004, 06:09 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i tried ur given code but it didnt work.


i just want to avoid given images an id because
ther are like 100 pictutesr that u can choose from in right.html

and by clicking on any of these pictures the chosen picture will
appear in the empty frame (left.html)


i thought the code was easy to create but i cant make it work

any suggestions on how to avoid the use of id and and to make pictures to act the way i want them to

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.