image swap

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

image swap

 
0
  #1
Apr 29th, 2008
i am trying to write a function so that when a user enters onto a page selected images change with each page that is entered. the page uses an iframe to load the new data so i need to swap the images on the main page which holds the iframe inside it.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function swap_image{
  2. document['imgMain'].src = title_commissioning.jpg;
  3. }

in the body of the page
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. onload="swap_image"

would the code look something like the code above or would it need to be expanded because the images that are being change are not in the iframe.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: image swap

 
0
  #2
Apr 29th, 2008
i ahve changed the code but it still is not working the code i have now looks like this

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function changeImage() {
  2. if (document.getElementById) {
  3. document.getElementById("image").style.background="images/home_title.jpg";
  4. }
  5. else if (document.all) {
  6. document.all["image"].style.background="images/home_title.jpg";
  7. }
  8. else if (document.layers) {
  9. document.layers["image"].style.background="images/home_title.jpg";
  10. }
  11. }

in the body tag

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. onload="changeImage()"

and were the image is displayed

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <td height="24" colspan="2" id="image" background="images/commissioning_title.jpg"></td>

i will kep looking for the solution if i find it i will post it. if anyone knows were to find the solution please post the address here.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: image swap

 
0
  #3
Apr 29th, 2008
still cannot get any code to work anyone know of any way to get the images to swap when the page is loaded. everything i have tried has failed up to i will keep trying though.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: image swap

 
0
  #4
Apr 29th, 2008
i ended up getting it work using iframes, i no it is not the same but it works.

i set the i frames to load different images in from a button click in the menu. it works fine and has no effect on the page loading times.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum


Views: 1717 | Replies: 3
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC