User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 375,219 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,277 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 615 | Replies: 3 | Solved
Reply
Join Date: Feb 2008
Posts: 271
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz in Training

image swap

  #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.

function swap_image{
    document['imgMain'].src = title_commissioning.jpg;
  }

in the body of the page
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Posts: 271
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz in Training

Re: image swap

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

function changeImage() {
if (document.getElementById) {
document.getElementById("image").style.background="images/home_title.jpg";
}
else if (document.all) {
document.all["image"].style.background="images/home_title.jpg";
}
else if (document.layers) {
document.layers["image"].style.background="images/home_title.jpg";
}
} 

in the body tag

onload="changeImage()"

and were the image is displayed

<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  
Join Date: Feb 2008
Posts: 271
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz in Training

Re: image swap

  #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  
Join Date: Feb 2008
Posts: 271
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz in Training

Re: image swap

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

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

All times are GMT -4. The time now is 3:27 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC