SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Dublin
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Rotating images in the main header

    I added a feature to my website that when every time the home page is refreshed the main image header changes. I rotate the images from a selection of 10 images.

    Iíve used JavaScript to do this. However there is a major problem which I did not foresee. The image is recognised as a popup and most browsers will now not display the main image header unless the user allows the popup.

    Is there another way to rotate images on refresh without using JavaScript?

    I can post the javascrip if you need to see it.

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could we have a link? Could an aminated gif be a possibility? Its really hard to tell withoug seeing

  3. #3
    Object Not Found junjun's Avatar
    Join Date
    Mar 2002
    Location
    northern MI
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe I'm being ignorant here; but I don't see a reason why 'most' browser would consider this a popup. You're having JS just write out the <img> tag right?

  4. #4
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Can you not use something server-side, like php or something? Would be a lot better.

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Dublin
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by elduderino
    Could we have a link? Could an aminated gif be a possibility? Its really hard to tell withoug seeing

    It's not live yet..............I'm testing the website locally.

  6. #6
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Dublin
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the code I'm using guys:


    <SCRIPT LANGUAGE="JavaScript">

    <!-- Begin
    // Set up the image files to be used.
    var theImages = new Array() //

    theImages[0] = '1.jpg'
    theImages[1] = '2.jpg'
    theImages[2] = 3.jpg'
    theImages[3] = 4.jpg'
    theImages[4] = 5.jpg'
    theImages[5] = 6.jpg'
    theImages[6] = 7.jpg'
    theImages[7] = 8.jpg'
    theImages[8] = 9.jpg'
    theImages[9] = 10.jpg'


    var j = 0
    var p = theImages.length;
    var preBuffer = new Array()
    for (i = 0; i < p; i++){
    preBuffer[i] = new Image()
    preBuffer[i].src = theImages[i]
    }
    var whichImage = Math.round(Math.random()*(p-1));
    function showImage(){
    document.write('<img src="'+theImages[whichImage]+'">');
    }

    // End -->
    </script>

    Then in the body of the HTML

    <SCRIPT LANGUAGE="JavaScript">


    <!-- Begin
    showImage();
    // End -->
    </script>

  7. #7
    Object Not Found junjun's Avatar
    Join Date
    Mar 2002
    Location
    northern MI
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cosmic, that codeshould not trigger any pop-up blockers. It's not a pop-up. Can you please put the page on the web somwhere so we can test as well?
    Why do you think pop-up blockers are stopping your images from displaying?

  8. #8
    SitePoint Wizard bronze trophy Tailslide's Avatar
    Join Date
    Feb 2006
    Location
    Bedford, UK
    Posts
    1,687
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this IE throwing up it's local security warning yellow bar thing?
    Little Blue Plane Web Design
    Blood, Sweat & Rust - A Land Rover restoration project

  9. #9
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Dublin
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry

    Quote Originally Posted by Tailslide
    Is this IE throwing up it's local security warning yellow bar thing?
    Yes!

    The bar says "To help protect your security, Internet Explorer has restricted this file from showing active content that could access you computer. Click here for options..."

  10. #10
    Guru Meditation Error gnarly's Avatar
    Join Date
    Dec 2003
    Location
    Cheltenham, United Kingdom
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, right, that's because you're running locally. Put the file on a server and IE won't show that anymore.
    Olly Hodgson
    thinkdrastic.net


Bookmarks

Posting Permissions

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