PDA

View Full Version : Switch Content Script - Validator?



isntworkdull
09-22-2008, 01:01 PM
1) Script Title: Switch Content Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm

3) Describe problem:

Hi all, This isnt a major problem, but i am using the above script and my page wont pass the WC3 validator because of the code :

bobexample.setStatus('<img src="../jscripts/close.gif" alt="close" /> ', '<img src="../jscripts/open.gif" alt="open" /> ')

the validator says :

Line 890, Column 68: document type does not allow element "img" here.

"../jscripts/close.gif" alt="close" /> ', '<img src="../jscripts/open.gif" al....

anyone know a way around this? worse comes to the worse i will just leave it as is and not have the page validated as i like this script.

thanks
James

ddadmin
09-22-2008, 07:43 PM
If the status HTML will always be images, you can modify the script so you merely enter the paths to the images (instead of its entire HTML), and have the script output the image accordingly. Inside the .js file, edit the setStatus() function so it looks like this instead (changes in red):


switchcontent.prototype.setStatus=function(openHTML, closeHTML){ //PUBLIC: Set open/ closing HTML indicator. Optional
this.statusOpen='<img src="'+openHTML+'" alt="open" />'
this.statusClosed='<img src="'+closeHTML+'" alt="close" />'
}

Then, in your HTML when calling this method, do:


bobexample.setStatus('../jscripts/close.gif', '../jscripts/open.gif')

isntworkdull
09-22-2008, 09:45 PM
fantastic...

did the job...

thanks very much

james