/    Sign up×
Community /Pin to ProfileBookmark

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}}[/CODE]

whats holding me back
if you need to see how it works on my site here is the URL.
[url]http://foxarch.com/portfolio/Restaurants/00056_DairyQueen/index.htm[/url]

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@toicontienJul 11.2007 — Do you have the variable [B]filterstring[/B] 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 [B]createPopup[/B]?
Copy linkTweet thisAlerts:
@SothpawMagnusauthorJul 11.2007 — 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()
}[/CODE]
Copy linkTweet thisAlerts:
@HazardTWJul 11.2007 — line: 56

Char: 1

Error: 'filterstring' is undefined

Code: 0[/QUOTE]


That's the error IE7 gives me.
Copy linkTweet thisAlerts:
@SothpawMagnusauthorJul 11.2007 — so that would be this line
[CODE]imgobj.filters[0].Apply()[/CODE]
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()
}[/CODE]

does anything look wrong to you...?
Copy linkTweet thisAlerts:
@toicontienJul 11.2007 — If you haven't defined filterstring yet, it will generate a JavaScript error in IE. I'd say get rid of the ...
if (imgobj.filters &amp;&amp; window.createPopup){
imgobj.style.filter=filterstring
imgobj.filters[0].Apply()
}

code all together.
Copy linkTweet thisAlerts:
@SothpawMagnusauthorJul 11.2007 — 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
Copy linkTweet thisAlerts:
@toicontienJul 11.2007 — 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.
Copy linkTweet thisAlerts:
@SothpawMagnusauthorJul 11.2007 — 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}}[/CODE]
Copy linkTweet thisAlerts:
@HazardTWJul 11.2007 — 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.
Copy linkTweet thisAlerts:
@SothpawMagnusauthorJul 11.2007 — 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. :-)
Copy linkTweet thisAlerts:
@toicontienJul 11.2007 — 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 [I]so[/I] important to give any error messages you are receiving, be they JavaScript errors or notifications from the browser.
Copy linkTweet thisAlerts:
@HazardTWJul 11.2007 — 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. ?
×

Success!

Help @SothpawMagnus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...