View Full Version : error from a script, yet, i don't see any error in the script

Uchiha Sasuke
01-02-2004, 02:42 AM
alright, here's my problem
i created a script, but when ever i put this script in, i gett eh error icon in the bottom left hand corner of my browser (IE) yet i can't seem to find the error in my script, nor can any or my other friends
this script was made to replace the main top tables of a Proboards remotely hosted forum
this is the URL to my forums, where the script is curently being used
now, what i'm guessing could be the problem aera is the rollover image mapping, yet i don't see any mistake >_<!!
if i could recieve some assitance with what my problem could be, i'd much appreciate it!
thanks you
here is the script (i bold'ed is the rollover mapping)

<Script Language="JavaScript">
Header Table Image Replacement

Images Provided by Imusion, Coding Supported by Uchiha Sasuke and Peter. Coding, and Images of this Header are Copyrighted, so Please don't Use, or Hotlink. Code May not be Reposted with out Express Permission From Uchiha Sasuke. Thank You.
Special Thanks to Fla5hba5h for helping to get this to work cross-browser

var ProLink=""
var A = document.getElementsByTagName("A")
if(A[a].href.indexOf("action=profile&username=") != -1){
if (document.getElementsByTagName('TD')[2].innerHTML.match(/ 0 /i)) { var PM = 'nonewPMs.gif'; var alt = 'No New Private Messages'; var PMmap = '#No New PM';}
else if (document.getElementsByTagName('TD')[2].innerHTML.match(/ 1 /)) {var PM = 'newPM.gif'; var alt = 'You Have A New Private Message'; var PMmap = '#New PM';}
else {var PM = 'newPMs.gif'; var alt = 'You Have New Private Messages'; var PMmap = '#New PM';}
var src = 'http://members.lycos.co.uk/deathbladedojo/'
var adminimg = 'http://members.lycos.co.uk/dragoondeathblade/hpbimg/admin.jpg'

if (document.getElementsByTagName('TD')[2].innerHTML.match(/Welcome /i)) {var loginimg = 'guest'; var map = '#DeathbladeDojoHeaderGuest'; var name = 'img';}
else if (document.getElementsByTagName('td')[5].innerHTML.match(''+adminimg+'')) {var loginimg= 'admin'; var map = '#DeathbladeDojoHeaderAdmin'; var name = 'image'; var pmc = 'img src="'+src+''+PM+'" border=0 alt="'+alt+'" usemap="'+PMmap+'"';}
else {var loginimg= 'member'; var map = '#DeathbladeDojoHeaderMember'; var name = 'images'; var pmc = 'img src="'+src+''+PM+'" border=0 alt="'+alt+'" usemap="'+PMmap+'"';}

var create_span_tag = document.createElement( "span" )
create_span_tag.innerHTML = '<center><IMG SRC="'+src+''+loginimg+'.gif" alt="Deathblade Dojo 2.0" BORDER=0 USEMAP="'+map+'" name="'+name+'"><'+pmc+'></center><MAP NAME="No New PM"><AREA SHAPE="rect" COORDS="7,1,25,8" HREF="?action=im"><AREA SHAPE="rect" COORDS="628,1,702,8" HREF="?action=im"></MAP><MAP NAME="New PM"><AREA SHAPE="rect" COORDS="8,1,24,7" HREF="?action=im"><AREA SHAPE="rect" COORDS="648,1,701,9" HREF="?action=im"></MAP><MAP NAME="DeathbladeDojoHeaderAdmin"><AREA SHAPE="rect" ALT="Recieve Help" Onmouseover="document.image.src=\''+src+''+loginimg+'FAQ.gif\'" onmouseout="document.image.src=\''+src+''+loginimg+'.gif\'" COORDS="606,105,641,115" HREF="http://proboards8.com/help/" TARGET="_blank"><AREA SHAPE="rect" ALT="Newest Announcements" COORDS="642,105,693,115" Onmouseover="document.image.src=\''+src+''+loginimg+'portal.gif\'" onmouseout="document.image.src=\''+src+''+loginimg+'.gif\'" HREF="?type=portal"><AREA SHAPE="rect" ALT="View The Deathblade Dojo Members" Onmouseover="document.image.src=\''+src+''+loginimg+'members.gif\'" onmouseout="document.image.src=\''+src+''+loginimg+'.gif\'" COORDS="540,104,605,115" HREF="?action=mlall"><AREA SHAPE="rect" ALT="Logout Of User" COORDS="483,104,539,115" Onmouseover="document.image.src=\''+src+''+loginimg+'logout.gif\'" onmouseout=;document.image.src=\''+src+''+loginimg+'.gif\'" HREF="?action=logout"><AREA SHAPE="rect" ALT="Register To The Deathblade Dojo Forums" COORDS="412,104,482,115" Onmouseover="document.image.src=\''+src+''+loginimg+'register.gif\'" onmouseout="document.image.src=\''+src+''+loginimg+'.gif\'" HREF="?action=register"><AREA SHAPE="rect" ALT="Edit Your Personal Information" COORDS="348,104,411,115" Onmouseover="document.image.src=\''+src+''+loginimg+'usercp.gif\'" onmouseout="document.image.src=\''+src+''+loginimg+'.gif\'" HREF="' + ProLink + '"><AREA SHAPE="rect" ALT="Administrative Controles" COORDS="297,104,347,115" Onmouseover="document.image.src=\''+src+''+loginimg+'admin.gif\'" onmouseout="document.image.src=\''+src+''+loginimg+'.gif\'" HREF="?action=admin"><AREA SHAPE="rect" ALT="Login To User" COORDS="247,104,296,115" Onmouseover="document.image.src=\''+src+''+loginimg+'login.gif\'" onmouseout="document.image.src=\''+src+''+loginimg+'.gif\'" HREF="?action=login"><AREA SHAPE="poly" ALT="Return To Home Page" COORDS="204,104, 193,116, 247,116, 247,104" Onmouseover="document.image.src=\''+src+''+loginimg+'home.gif\'" onmouseout="document.image.src=\''+src+''+loginimg+'.gif\'" HREF="index.cgi"></MAP><MAP NAME="DeathbladeDojoHeaderMember"><AREA SHAPE="rect" ALT="Newest Announcements" COORDS="591,105,642,116" Onmouseover="document.images.src=\''+src+''+loginimg+'portal.gif\'" onmouseout="document.images.src=\''+src+''+loginimg+'.gif\'" HREF="?type=portal"><AREA SHAPE="rect" ALT="Recieve Help" COORDS="555,105,590,116" Onmouseover="document.images.src=\''+src+''+loginimg+'FAQ.gif\'" onmouseout="document.images.src=\''+src+''+loginimg+'.gif\'" HREF="http://proboards8.com/help/" TARGET="_blank"><AREA SHAPE="rect" ALT="View The Deathblade Dojo Members" COORDS="489,105,554,116" Onmouseover="document.images.src=\''+src+''+loginimg+'members.gif\'" onmouseout="document.images.src=\''+src+''+loginimg+'.gif\'" HREF="?action=mlall"><AREA SHAPE="rect" ALT="Logout Of User" COORDS="432,105,488,116" Onmouseover="document.images.src=\''+src+''+loginimg+'logout.gif\'" onmouseout="document.images.src=\''+src+''+loginimg+'.gif\'" HREF="?action=logout"><AREA SHAPE="rect" ALT="Register To The Deathblade Dojo Forums" COORDS="361,105,431,116" Onmouseover="document.images.src=\''+src+''+loginimg+'register.gif\'" onmouseout="document.images.src=\''+src+''+loginimg+'.gif\'" HREF="?action=register"><AREA SHAPE="rect" ALT="Edit Your Personal Information" COORDS="297,105,360,116" Onmouseover="document.images.src=\''+src+''+loginimg+'usercp.gif\'" onmouseout="document.images.src=\''+src+''+loginimg+'.gif\'" HREF="' + ProLink + '"><AREA SHAPE="rect" ALT="Login To User" COORDS="247,105,296,116" Onmouseover="document.images.src=\''+src+''+loginimg+'login.gif\'" onmouseout="document.images.src=\''+src+''+loginimg+'.gif\'" HREF="?action=login"><AREA SHAPE="poly" ALT="Return To Home Page" Onmouseover="document.images.src=\''+src+''+loginimg+'home.gif\'" onmouseout="document.images.src=\''+src+''+loginimg+'.gif\'" COORDS="192,118, 204,105, 247,105, 247,117, 193,117" HREF="index.cgi"></MAP><MAP NAME="DeathbladeDojoHeaderGuest"><AREA SHAPE="rect" ALT="Register To The Deathblade Dojo Forums" COORDS="334,105,402,115" Onmouseover="document.img.src=\''+src+''+loginimg+'register.gif\'" onmouseout="document.img.src=\''+src+''+loginimg+'.gif\'" HREF="?action=register"><AREA SHAPE="rect" ALT="Newest Announcements" COORDS="403,105,454,115" Onmouseover="document.img.src=\''+src+''+loginimg+'portal.gif\'" onmouseout="document.img.src=\''+src+''+loginimg+'.gif\'" HREF="?type=portal"><AREA SHAPE="rect" ALT="Recieve Help" COORDS="297,104,334,116" Onmouseover="document.img.src=\''+src+''+loginimg+'FAQ.gif\'" onmouseout="document.img.src=\''+src+''+loginimg+'.gif\'" HREF="http://proboards8.com/help/" target="_blank"><AREA SHAPE="rect" ALT="Login To User" COORDS="247,104,296,116" Onmouseover="document.img.src=\''+src+''+loginimg+'login.gif\'" onmouseout="document.img.src=\''+src+''+loginimg+'.gif\'" HREF="?action=login"><AREA SHAPE="poly" ALT="Return To Home Page" COORDS="205,104, 192,117, 247,117, 247,104" Onmouseover="document.img.src=\''+src+''+loginimg+'home.gif\'" onmouseout="document.img.src=\''+src+''+loginimg+'.gif\'" HREF="index.cgi"></MAP>'
var header = document.getElementsByTagName("table")[0]
header.parentNode.replaceChild( create_span_tag , header )

01-02-2004, 03:11 PM
Double click on the error icon and will give you the details of the error.

01-02-2004, 04:01 PM
The errors I'm getting are:

Error: A[a].href has no properties
Source File: http://hokuro.proboards19.com/index.cgi
Line: 775

And also...

Error: document.body.createTextRange is not a function
Source File: http://hokuro.proboards19.com/index.cgi
Line: 1292

The first may be something to look into. Although JavaScript is case-sensitive, using A and a as variables might not be the best idea.

For the second, I'm not too sure about createTextRange(). Is that proprietary-IE or is it part of the real W3C specification? Assuming it's a valid W3C function, you might try using document.getElementsByTagName('body')[0].createTextRange();

Hope this helps!

01-02-2004, 05:35 PM
For the second, I'm not too sure about createTextRange(). Is that proprietary-IE or is it part of the real W3C specification?

TextRange is IE-proprietary, and created by elementObj.createTextRange(). Range is W3C, and created by document.createRange().

Hope that helps!

Happy coding! :)

Uchiha Sasuke
01-02-2004, 11:03 PM
well thing is, i took out all IE only properties, so i could be viewed on mozzila and such, so i have no clue where that document.body.createTextRange came from in that error...

but when i get my error message, it says the cuase is a "unterminated string constant"
yet i have no clue what they mean by that, and where it is in the coding...

thanks for the help ^_^

01-03-2004, 01:53 AM
Unterminated string constant I believe is the same thing as unterminated string literal. An example would be something like this:

var s = "My name is Larry; //this will produce an error, because the string literal is unterminated;

Most likely, somewhere in that very large string of yours you made a mistake with your quotation marks, both single and double. Consider separating the whole string into many additions, using the add-by-value (+=) operator. It would be easy, I imagine, to get lost in such a big, endless string.

You might even want to consider an alternative way of doing this, as appending a giant string of HTML with JavaScript isn't very practical.

Hope that helps!

Happy coding! :)

Uchiha Sasuke
01-04-2004, 04:57 AM
but, all my strings are terminated, everything has been ended perfectly, or else the coding wouldn't work rather than just a error message, and i checked it over too

this is so weird....