Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Forum How-To (http://forum.bytesforall.com/forumdisplay.php?f=9)
-   -   [SOLVED] Adding javascript to atahualpa (http://forum.bytesforall.com/showthread.php?t=14385)

DanDan May 27, 2011 04:06 PM

[SOLVED] Adding javascript to atahualpa
 
I am trying to add rollover buttons in a sidebar widget. The code was generated by image ready and it works fine on the page that was generated. i copied the code into the head and the body tag using the Add HTML/CSS inserts feature but I am getting a javascript error. What could be wrong?

Thanks,

Dan

juggledad May 27, 2011 08:08 PM

Where exactly did you add it?

DanDan May 27, 2011 08:46 PM

I added the javascript to the head, added an ONLOAD statement to the body tag and added the rollover buttons to a widget in a sidebar.

juggledad May 28, 2011 04:22 AM

what is the error and what is the code?

DanDan May 28, 2011 08:11 AM

This was added to the head:

<SCRIPT LANGUAGE="JavaScript">
<!--

function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}

var preloadFlag = false;
function preloadImages() {
if (document.images) {
social_logos_01_over = newImage("images/social_logos_01-over.jpg");
social_logos_02_over = newImage("images/social_logos_02-over.jpg");
social_logos_03_over = newImage("images/social_logos_03-over.jpg");
social_logos_04_over = newImage("images/social_logos_04-over.jpg");
preloadFlag = true;
}
}

// -->
</SCRIPT>


This was added to the body tag:

ONLOAD="preloadImages();"

This was added to the widget in the sidebar:

<TABLE WIDTH=204 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD>
<A HREF="#"
ONMOUSEOVER="changeImages('social_logos_01', 'images/social_logos_01-over.jpg'); return true;"
ONMOUSEOUT="changeImages('social_logos_01', 'images/social_logos_01.jpg'); return true;">
<IMG NAME="social_logos_01" SRC="images/social_logos_01.jpg" WIDTH=50 HEIGHT=46 BORDER=0></A></TD>
<TD>
<A HREF="#"
ONMOUSEOVER="changeImages('social_logos_02', 'images/social_logos_02-over.jpg'); return true;"
ONMOUSEOUT="changeImages('social_logos_02', 'images/social_logos_02.jpg'); return true;">
<IMG NAME="social_logos_02" SRC="images/social_logos_02.jpg" WIDTH=50 HEIGHT=46 BORDER=0></A></TD>
<TD>
<A HREF="#"
ONMOUSEOVER="changeImages('social_logos_03', 'images/social_logos_03-over.jpg'); return true;"
ONMOUSEOUT="changeImages('social_logos_03', 'images/social_logos_03.jpg'); return true;">
<IMG NAME="social_logos_03" SRC="images/social_logos_03.jpg" WIDTH=55 HEIGHT=46 BORDER=0></A></TD>
<TD>
<A HREF="#"
ONMOUSEOVER="changeImages('social_logos_04', 'images/social_logos_04-over.jpg'); return true;"
ONMOUSEOUT="changeImages('social_logos_04', 'images/social_logos_04.jpg'); return true;">
<IMG NAME="social_logos_04" SRC="images/social_logos_04.jpg" WIDTH=49 HEIGHT=46 BORDER=0></A></TD>
</TR>
</TABLE>

This was the error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; EmbeddedWB 14.52 Embedded Web Browser from: http://bsalsa.com/; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C)
Timestamp: Sat, 28 May 2011 14:11:30 UTC


Message: Object expected
Line: 24
Char: 1
Code: 0
URI: http://knottydaughters.com/?cat=5


Message: Object expected
Line: 24
Char: 1
Code: 0
URI: http://knottydaughters.com/?cat=5


Message: Object expected
Line: 24
Char: 1
Code: 0
URI: http://knottydaughters.com/?cat=5


Message: Object expected
Line: 24
Char: 1
Code: 0
URI: http://knottydaughters.com/?cat=5


Message: Object expected
Line: 24
Char: 1
Code: 0
URI: http://knottydaughters.com/?cat=5

juggledad May 28, 2011 11:45 AM

Well, I just dumped that code on my site, copied the images and it works fine in Safari and FireFox on a mac.

(not a good Idea to have a folder 'images' in the wordpress root - move it to the wp-content folder so it won't get wiped out on a wordpress upgrade)

DanDan May 28, 2011 01:26 PM

I was trying it on a PC with IE so I tried it on Firefox. No error message but the rollovers don't work. Using IE I get an error as soon as the page loads. See it at http://knottydaughters.com to see it in it's actual environment.

juggledad May 28, 2011 03:41 PM

I Beleive you are using 367, apply the bugfix's (New Versions & Updates forum) and I think your issue will be resolved.

DanDan May 28, 2011 06:37 PM

That did it! I added the css.php file and it corrected it in both IE and Firefox.

Thanks!

Dan


All times are GMT -6. The time now is 04:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.