www.webdeveloper.com
Results 1 to 13 of 13

Thread: Rollover doesn't work in IE

  1. #1
    Join Date
    Jul 2007
    Posts
    24

    Rollover doesn't work in IE

    the below JS works fine in FF but not IE.

    Code:
    var dynimages=new Array()
    dynimages[1]=["001.jpg", ""]
    dynimages[2]=["002.jpg", ""]
    dynimages[3]=["003.jpg", ""]
    
    var preloadimg="yes"
    
    var optlinktarget=""
    
    var imgborderwidth=0
    
    preloads = new Array();
    
    if (preloadimg=="yes"){ 
      for (x=1; x<dynimages.length; x++){ 
        preloads[x] = new Image();
        preloads[x].src = dynimages[x][0]
    }
    }
    function returnimgcode(theimg){
    var imghtml=""
    if (theimg[1]!="")
    imghtml='<a href="'+theimg[1]+'" target="'+optlinktarget+'">'
    imghtml+='<img src="'+theimg[0]+'" width="100%" border="'+imgborderwidth+'">'
    if (theimg[1]!="")
    imghtml+='</a>'
    return imghtml
    }
    function modifyimage(loadarea, imgindex){
    if (document.getElementById){
    var imgobj=document.getElementById(loadarea)
    if (imgobj.filters && window.createPopup){
    imgobj.style.filter=filterstring
    imgobj.filters[0].Apply()
    }
    imgobj.innerHTML=returnimgcode(dynimages[imgindex])
    imgobj.filters[0].Play()
    return false}}
    whats holding me back
    if you need to see how it works on my site here is the URL.
    http://foxarch.com/portfolio/Restaur...ueen/index.htm

  2. #2
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,755
    Do you have the variable filterstring defined anywhere? Even if that variable is an empty string, you might be running into JavaScript errors, as there are no filters to play in that case. Secondly, is there a global function defined called createPopup?

  3. #3
    Join Date
    Jul 2007
    Posts
    24
    both are in there.
    someone once said something about the createPopup and i tried deleting it but then the rollover didn't work.
    Code:
    function modifyimage(loadarea, imgindex){
    if (document.getElementById){
    var imgobj=document.getElementById(loadarea)
    if (imgobj.filters && window.createPopup){
    imgobj.style.filter=filterstring
    imgobj.filters[0].Apply()
    }

  4. #4
    Join Date
    Apr 2007
    Posts
    153
    line: 56
    Char: 1
    Error: 'filterstring' is undefined
    Code: 0
    That's the error IE7 gives me.

  5. #5
    Join Date
    Jul 2007
    Posts
    24
    so that would be this line
    Code:
    imgobj.filters[0].Apply()
    from this group
    Code:
    function modifyimage(loadarea, imgindex){
    if (document.getElementById){
    var imgobj=document.getElementById(loadarea)
    if (imgobj.filters && window.createPopup){
    imgobj.style.filter=filterstring
    imgobj.filters[0].Apply()
    }
    does anything look wrong to you...?

  6. #6
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,755
    If you haven't defined filterstring yet, it will generate a JavaScript error in IE. I'd say get rid of the ...
    Code:
    if (imgobj.filters && window.createPopup){
    imgobj.style.filter=filterstring
    imgobj.filters[0].Apply()
    }
    code all together.

  7. #7
    Join Date
    Jul 2007
    Posts
    24
    it's always messy working with someone elses previous riped code.
    ok it works in FF without those lines of code... but still not IE

  8. #8
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,755
    You're getting a JavaScript error somewhere. Can you post the error you are getting? This will be something generated by the browser. And then you need to post the full JavaScript -- all the JavaScript for the page.

  9. #9
    Join Date
    Jul 2007
    Posts
    24
    here is the error i get in IE
    "to help protect your security, Internet Explorer has restricted this webpage from running scripts or ActiveX controls that could access your computer. Click here for options."
    so i clicked and allowed the blocked content and all of a sudden the roll over works. but if something my code is causing that error...
    Code:
    var dynimages=new Array()
    dynimages[1]=["001.jpg", ""]
    dynimages[2]=["002.jpg", ""]
    dynimages[3]=["003.jpg", ""]
    
    var preloadimg="yes"
    
    var optlinktarget=""
    
    var imgborderwidth=0
    
    preloads = new Array();
    
    if (preloadimg=="yes"){ 
      for (x=1; x<dynimages.length; x++){ 
        preloads[x] = new Image();
        preloads[x].src = dynimages[x][0]
    }
    }
    function returnimgcode(theimg){
    var imghtml=""
    if (theimg[1]!="")
    imghtml='<a href="'+theimg[1]+'" target="'+optlinktarget+'">'
    imghtml+='<img src="'+theimg[0]+'" width="100%" border="'+imgborderwidth+'">'
    if (theimg[1]!="")
    imghtml+='</a>'
    return imghtml
    }
    function modifyimage(loadarea, imgindex){
    if (document.getElementById){
    var imgobj=document.getElementById(loadarea)
    imgobj.innerHTML=returnimgcode(dynimages[imgindex])
    imgobj.filters[0].Play()
    return false}}

  10. #10
    Join Date
    Apr 2007
    Posts
    153
    That's just IE trying to protect you, once you allow blocked content and it works without errors, you should be good to go.

    Did you upload the changed code to the URL provided? I still get the same error.

  11. #11
    Join Date
    Jul 2007
    Posts
    24
    you guys are geniuses... and here i thought i knew a ton about web design... (more than anyone at my office anyway) it must make you feel good to know all the answers.
    thanks again for a job well done.
    you even made my JS file smaller. :-)

  12. #12
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,755
    IE-Win, as of several windows updates ago, prevents all JavaScript from running if it comes from a file on your hard drive. There is a setting in the IE-Win options to allow active scripting in this situation. The problem was a security setting all along. This is why it's so important to give any error messages you are receiving, be they JavaScript errors or notifications from the browser.

  13. #13
    Join Date
    Apr 2007
    Posts
    153
    One way to learn is to come to a place like these forums and try to solve other peoples problems that you don't already know the answer to, that way when you eventually run into a similar problem, you will know what to do.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles