...

View Full Version : non-validated script



StickBoy
06-01-2003, 08:45 PM
I have the following script in my web page:

<SCRIPT TYPE="text/javascript">
var ebimagetag='<iframe name="ebay-table" frameborder=0 WIDTH=430 HEIGHT=205 MARGINWIDTH=0 MARGINHEIGHT=0 ALIGN=CENTER src="auction.htm"></iframe>'

var ebbutton='<iframe name="ebay-button" frameborder="0" WIDTH=92 HEIGHT=35 MARGINWIDTH=0 MARGINHEIGHT=0 ALIGN="CENTER" src="button.htm"></iframe>'

var today=new Date()

function ebexpireat(expiredate){

var expire=new Date(expiredate)

if (today.getTime()<=expire.getTime())
document.write(ebimagetag)
else
document.write(ebbutton)
}
</script>

When I use the W3C Validator, it tells me that it is wrong, and points out the "end tag for element "IFRAME" which is not open". I tried eliminating the </iframe> tag (in hopes that it was optional), but then the iframe doesn't show at all.

Although that little W3C-approved sticker is not such a big deal, it's a source of pride that I can display it, and this is the only thing stopping me from doing so. Is there a better, approved way of scripting what I want?

whammy
06-02-2003, 08:23 PM
You probably had incorrectly nested elements, which caused the validator to give you that error message. Try putting the IFRAME tags back in, but make sure that everything is nested correctly.

MotherNatrsSon
06-02-2003, 09:47 PM
I use three different scripts from Dynamic Drive on my site currently and every single one does not validate. If I make the changes necessary for validation the script no longer works. I think the W3C validator needs some tweaking.

MNS

whammy
06-02-2003, 09:48 PM
I bet I could make 'em validate. Got a link?

MotherNatrsSon
06-02-2003, 09:53 PM
Ok. Give it your best shot. Here is one...

<script language="JavaScript">

//Comment trail script- By Kurt (kurt.grigg@virgin.net)
//Script featured on Dynamic Drive
//Visit http://www.dynamicdrive.com for this script and more

colours=new Array('#D1C2D5','#D1C2D5','#D1C2D5','#D1C2D5','#D1C2D5','#D1C2D5','#D1C2D5','#D1C2D5','#D1C2D5')
n = 8;
y = 0;
x = 0;
n6=(document.getElementById&&!document.all);
ns=(document.layers);
ie=(document.all);
d=(ns||ie)?'document.':'document.getElementById("';
a=(ns||n6)?'':'all.';
n6r=(n6)?'")':'';
s=(ns)?'':'.style';
if (ns){
for (i = 0; i < n; i++)
document.write('<layer name="dots'+i+'" top=0 left=0 width='+i/2+' height='+i/2+' bgcolor=#ff0000></layer>');
}
if (ie)
document.write('<div id="con" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
if (ie||n6){
for (i = 0; i < n; i++)
document.write('<div id="dots'+i+'" style="position:absolute;top:0px;left:0px;width:'+i/2+'px;height:'+i/2+'px;background:#ff0000;font-size:'+i/2+'"></div>');
}
if (ie)
document.write('</div></div>');
(ns||n6)?window.captureEvents(Event.MOUSEMOVE):0;
function Mouse(evnt){
y = (ns||n6)?evnt.pageY+4 - window.pageYOffset:event.y+4;
x = (ns||n6)?evnt.pageX+1:event.x+1;
}
(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
function animate(){
o=(ns||n6)?window.pageYOffset:0;
if (ie)con.style.top=document.body.scrollTop;
for (i = 0; i < n; i++){
var temp1 = eval(d+a+"dots"+i+n6r+s);

randcolours = colours[Math.floor(Math.random()*colours.length)];
(ns)?temp1.bgColor = randcolours:temp1.background = randcolours;
if (i < n-1){
var temp2 = eval(d+a+"dots"+(i+1)+n6r+s);
temp1.top = parseInt(temp2.top);
temp1.left = parseInt(temp2.left);
}
else{
temp1.top = y+o;
temp1.left = x;
}
}
setTimeout("animate()",120);
}
animate();
// -->

</script>

AND HERE IS THE OTHERS...

<script>

//Thumbnail image viewer-
// Dynamic Drive (www.dynamicdrive.com)
//For full source code, usage terms, and 100's more DHTML scripts, visit http://www.dynamicdrive.com

var ie=document.all
var ns=document.layers
var ns6=document.getElementById&&!document.all

function enlarge(which,e){
//Render image code for IE 4+ and NS6
if (ie||ns6){
crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
if (crossobj.style.visibility=="hidden"){
crossobj.style.left=ns6? pageXOffset+e.clientX : document.body.scrollLeft+event.clientX
crossobj.style.top=ns6? pageYOffset+e.clientY : document.body.scrollTop+event.clientY
crossobj.innerHTML='<div align=right id=drag><b onClick=closepreview()>X</b></div><img src="'+which+'">'
crossobj.style.visibility="visible"
}
else
crossobj.style.visibility="hidden"
return false
}
//Render image code for NS 4
else if (document.layers){
if (document.showimage.visibility=="hide"){
document.showimage.document.write('<a href="#" onMouseover="drag_dropns(showimage)"><img src="'+which+'" border=0></a>')
document.showimage.document.close()
document.showimage.left=e.x
document.showimage.top=e.y
document.showimage.visibility="show"
}
else
document.showimage.visibility="hide"
return false
}
//if NOT IE 4+ or NS 4, simply display image in full browser window
else
return true
}

function closepreview(){
crossobj.style.visibility="hidden"
}

</script>
<script language="JavaScript1.2">

//By Dynamicdrive.com

//drag drop function for NS 4////
/////////////////////////////////

var nsx,nsy,nstemp

function drag_dropns(name){
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for IE 4+ and NS6////
/////////////////////////////////

function drag_drop(e){
if (ie&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx
crossobj.style.top=tempy+e.clientY-offsety
}
return false
}

function initializedrag(e){
if (ie&&event.srcElement.id=="drag"||ns6&&e.target.id=="drag"){
offsetx=ie? event.clientX : e.clientX
offsety=ie? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}

document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")


</script>

MNS

whammy
06-02-2003, 09:55 PM
Oh, I meant a link to your page... can't validate the scripts alone, the entire HTML of your page must be validated with the scripts included.

MotherNatrsSon
06-02-2003, 10:04 PM
Ok. Here is the link to one page with the cursor script. My Test Page (http://www.feminineoptions.com/TheOne9.html) It passes except for 8 errors, 7 of which are in the cursor script. If I make the changes and put the doc type for 4.01 transitional into it the script ceases to work.

The other files are in the zip. I do not have them up on the web yet. The same thing with them. They use the thumbnail script and if I make the changes and put the 4.01 transitional doc type on the page they cease to function in all browsers.

I will be interested to see what you come up with because it has baffled me.

MNS

whammy
06-03-2003, 12:14 AM
Well I did it in XHTML 1.0 Strict for your test page, but it's really just a matter of going through each error step by step, and seeing how you can fix it.:

http://validator.w3.org/check?uri=http%3A%2F%2Fwww.solidscripts.com%2Fscripttest%2FTheOne9.htm&charset=%28detect+automatically%29&doctype=%28detect+automatically%29

:)

StickBoy
06-03-2003, 02:12 AM
Originally posted by whammy
You probably had incorrectly nested elements, which caused the validator to give you that error message. Try putting the IFRAME tags back in, but make sure that everything is nested correctly.

Well, you can see how everything is nested by the code I posted. That is in the <HEAD> section of the page. I don't see anything in there that is out of place, but I would appreciate if you would have a look and see if you can spot what's wrong: http://www3.telus.net/beedersbeads/index.htm

MotherNatrsSon
06-03-2003, 02:14 AM
Like I said though, when I fix the errors it says I have and attach the doc type the script doesn't work in older browsers. That my friend is the trick and the problem. I didn't try it in xhtml because I didn't think it was anywhere close to it by comparing the code to other xhtml pages I have seen. Most are either asp or php too though. Any luck with the other pages?

MNS

MotherNatrsSon
06-03-2003, 02:28 AM
Stickboy. These ae the erors I got from w3C when validating your page...

1. Line 15, column 45: required attribute "TYPE" not specified (explain...).

<SCRIPT LANGUAGE="JavaScript" SRC="images.js"></SCRIPT>
^

2. Line 17, column 7: required attribute "TYPE" not specified (explain...).

<script>
^

3. Line 18, column 145: end tag for element "IFRAME" which is not open (explain...).

...IGN=CENTER src="auction.htm"></iframe>'
^

4. Line 19, column 145: end tag for element "IFRAME" which is not open (explain...).

...GN="CENTER" src="button.htm"></iframe>'
^

5. Line 29, column 144: end tag for element "IFRAME" which is not open (explain...).

...GN=CENTER src="auction2.htm"></iframe>'
^

6. Line 30, column 145: end tag for element "IFRAME" which is not open (explain...).

...N="CENTER" src="button2.htm"></iframe>'
^

7. Line 40, column 147: end tag for element "IFRAME" which is not open (explain...).

...GN=CENTER src="auction3.htm"></iframe>'
^

8. Line 48, column 145: end tag for element "IFRAME" which is not open (explain...).

...GN=CENTER src="auction4.htm"></iframe>'
^

9. Line 71, column 12: an attribute value must be a literal unless it contains only name characters (explain...).

<HR WIDTH=25%>
^

10. Line 93, column 7: required attribute "TYPE" not specified (explain...).

<script>
^

11. Line 98, column 7: required attribute "TYPE" not specified (explain...).

<script>
^

12. Line 103, column 7: required attribute "TYPE" not specified (explain...).

<script>
^

13. Line 108, column 7: required attribute "TYPE" not specified (explain...).

<script>
^

14. Line 114, column 44: required attribute "TYPE" not specified (explain...).

<font size="2"><SCRIPT LANGUAGE="JavaScript">
^

15. Line 127, column 38: end tag for element "A" which is not open (explain...).

document.write('">Add to Favourites</a>');
^

16. Line 137, column 10: end tag for element "P" which is not open (explain...).

</font></p>
^

17. Line 143, column 117: required attribute "ALT" not specified (explain...).

... HEIGHT=20 BORDER=0 HSPACE=4 VSPACE=2>
^


To get rid of the iframe error someone told me in another thread to make the tag look like this <\/iframe> It gets rid of the error but then I couldn't get the script to work either. I have the </a> tags as well as </div> tags in the scripts I am using and it does the same thing. Fixes the errors according to the valifator but then the script ceases to function. That is why I said the w3C validator needs to recognize those as a necessary part of the script and not say it is an error. They need to TWEAK it.

MNS

StickBoy
06-03-2003, 02:40 AM
Agh! Look at all those errors!
This is what happens when you validate the file while it's still on your computer - you forget to upload the corrections.

Aside from that, I have implemented your backslash and lo and behold, it works! The page is validated and the code does what it's supposed to do.

Thank you very much!

MotherNatrsSon
06-03-2003, 05:10 AM
That is great!! Glad it worked for you. If I do that with the scripts I am using, they validate but cease to work. I have asked for help with mine but haven't seen any.

MNS

Roy Sinclair
06-03-2003, 03:09 PM
Originally posted by MotherNatrsSon
That is great!! Glad it worked for you. If I do that with the scripts I am using, they validate but cease to work. I have asked for help with mine but haven't seen any.

MNS

But your pages make the same errors as stickboy's!

You left off the type="text/javascript" on the script tags and need to change the places where you have </ in your javascript with <\/ just like stickboy. Using HTML Tidy as a validator it took only a couple minutes to fix the problems (which are very few).

whammy
06-03-2003, 04:39 PM
Yup, it only took a couple of minutes to fix them on that first page, even without HTML Tidy - but I'd try that.

MotherNatrsSon
06-03-2003, 05:25 PM
Did you test the scripts in any browsers after you fixed them? I did. They cease to function in NS4x and IE5.1 for MAC both of which many visitors to my site use according to my site stats. That is why I think their validator needs tweaking and why I haven't made the "fixes" to the pages to get them validated. I have played with the validator and the doctype at the top of the page in various browsers. In some it has a very negative effect.

I am on a MAC and HTML Tidy is useless to me. There is no version of it for OS 9x. I do have BBEdit that does the same thing though.

MNS

Roy Sinclair
06-03-2003, 06:58 PM
Adding type="text/javascript" to your script tags breaks IE and NS on a Mac?

Using the "\" to escape the following character within a string breaks a script in IE and NS on a Mac?


Fixing just those small problems shouldn't break either browser on any platform, once those are fixed your page is valid according to Tidy. What other errors does the validator you're using give you?

MotherNatrsSon
06-03-2003, 07:13 PM
Those are the errors I fix. When I change the </div> tag </layer> tag and the </a> tags to look like this<\/div>, <\/layer> and <\/a> and put the doctype at the top of the page(4.01 transtional) and change the <script> tag IE 5.1.6 on a Mac refuses to run the scripts and the java error window opens up. In NS 4x the script functions with no errors but the layer that holds the larger image is "deformed". I am a "beginner" to all this and have no idea as to why other than making the changes necessary to validate and putting the doctype at the top of the code makes them not work.

BBEdit gives a couple more errors. Something about CDATA string being terminated abruptly. I have a thread in the Dynamic Drive forum with the errors from BBEdit pasted in there. http://www.codingforums.com/showthread.php?s=&threadid=20679]HERE

http://www.codingforums.com/showthread.php?s=&threadid=20761]HERE
The w3C validator gives the same as HTML Tidy.

MNS

Roy Sinclair
06-03-2003, 07:19 PM
Try making the fixes one at a time and check between each fix. There may be only one of them which is causing the whole problem and if you can isolate it to just one change it'll be closer to "valid" and will also allow a more narrow look at the offending change.

MotherNatrsSon
06-03-2003, 07:24 PM
The error is in this line according to IE java error alert:

crossobj.style.left=ns6? pageXOffset+e.clientX : document.body.scrollLeft+event.clientX

That is the error that IE throws up from one of the above posts in the Dynamic Drive threads.

MNS



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum