Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Image changer

  1. #1
    New Coder
    Join Date
    Dec 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Image changer

    I have a board where you can change the logo in the header, but want to change it for each forum, so it's a different image. I have this script.....

    Code:
    <script language="JavaScript">
    for(i=0 ; i<document.images.length ; i++){
    if(document.images[i].src=="URL HERE"){
    document.images[i].src="URL HERE"
    }
    }
    </script>
    Is there a way to change the image without the user noticing it change. Because at the moment when you goto into a forum, you see the previous image for a split second before it changes.

    Thanks

    Peter

  • #2
    Regular Coder
    Join Date
    May 2003
    Location
    Manassas, VA, USA
    Posts
    220
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It would probably be better if you used a server side script to do it. Just look in hotscripts.com under images for whatever language you need.

    -Andrew

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could set the initial SRC to a blank image, then change it to the real one; that way, you wouldn't see the previous image.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    document.images is depreciated, I guess because getElementsByTagName does the same thing.

    Code:
    css
    
    .myImages {
    visibility; hidden;
    }
    
    js
    
    var document_images = document.getElementsByTagName('img')
    var document_images_length = document_images.length
    
    for(i=0 ; i<document_images_length ; i++){
    if(document_images[i].src=="URL HERE"){
    document_images[i].src="URL HERE"
    document_images[i].style.visibility = 'visible'
    }
    }
    
    html
    
    <img class="myImage">
    I don't understand why you're using a loop. You don't need to if it's only 1 image per page

  • #5
    New Coder
    Join Date
    Dec 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Problem is, I can't change the HTML on the forum, I can only add to it, with JS, CSS, HTML etc. It's a remotely hosted forum.

    Thanks

    Peter


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •