OK I have just implemented a Javascript for rotating images into my page, however this causes my page to not validate as x1.0 transisitonal (creates 100+ errors!) I've read that this is because it cannot understand the javascript code, therefore i should export the script to an external .js file, and then the page will validate. The problem is i don't know how to do this, i tried moving it all across without success. Can anyone help me on how to do this? Im entering <script language="javaScript" src="ss.js"></script> onto my homepage. In short the script (ss.js) contains the following: <script type="text/javascript">script here</script> <script type="text/javascript">more script</script> then some html to create the image <script type="text/javascript">some more script</script> <noscript> more script </noscript> OK am i meant to delete the script, no script tags inside the js file? Also should the html to create the image be moved out of the js file into my html file?
remove all the tags and html code form the javascript file(ss.js)..just the fuctions should be reside in .js file and the functions be shud called from html page...try it ...or just send me the html file ..i will send the two seperated files(html and external js file)
Change <script language="javaScript" src="ss.js"></script> to <script language="javaScript" src="ss.js" type="text/javascript"></script> Actually you have not defined the TYPE in header code. May be its creating the problem.
hi, i tried both without luck, i have attached the code to the post, currently it's in a php include and works but obviously i need the script in a seperate .js file. Many thanks for your help it's really appreciated.
All the suggestions offered above are valid and also you can never validate that page as xhtml transitional if that is what you meant; move the files to seperate .js file and then link it up to the page Do not use a <script type> in the .js file Do not include any html code in the .js file Come back to your page and check your images if they have the alt="name" in the <img> Make sure your tags are properly nested make sure your tags are properly closed Then another issue to watch out if your <img> is also closed</img> i know its required either in transitional or strict but not too sure about that. Make sure you defined the page according to the type of validation you want or otherwise it wont validate Check your tags either you use a container tags <tag></tag> or alternative in xhtml <tag/>
Thanks, but the main problem is i can't get the script to work externally i am doing something wrong i have uploaded the code on the previous post that i need seperating into a js file to work properly, but i'm still unsure on how to do this.
Once You have separated the code to a .js file that means saving the page as a .js file upload the file to the same directory on the server Inside the html file exactly where you would like to run the script, then add the script below <script src="your file.js"> </script> "your file.js" being the separated javascript file stored in the same directory. You can use a partial url or full url for this. Place the .js file exactly where you would like to run the script in the page. either in <head> or <body> Make sure your .js file has no <script type> anywhere in the file One clue,if you have your .css file in another file, then you must try to validate as xhtml strict and not transitional
Nice one have transferred it sucessfully now it seems to take a while to load externally for some reason. Most of the errors are gone thankyou for your help. I have just a problem with 2 pieces on my page now, firstly it does not like the code i have used for my rotating image which is: <a href="javascript:SLIDES.hotlink()"><img name="SLIDESIMG" src="xx.jpg" style="filterrogidXImageTransform.Microsoft.Fade()" border=0 width="150px" height="150px" alt="xx" class="floatright"></a> Another is the line: <form action="forum/login.php" method="post" target="_top"> It says the document type does not allow the element "form" here? This causes 5 or 6 futher errors?
What are you validating the document as, Strict or transitional, Xhtml or html? for the form, i think the target should be target="top" and not target=_top" I hope im right there.
Ah, a couple of things, mds is mostly right except the <img> must be closed with the "empty" tag closing /> (unless that's what you originally meant, mds). The "empty" tags may NEVER be closed with </img> or </br> or </meta> or </link> and for compatibility between Xhtml and Html there should be a space between the tag part and the slash (<img src="whatever..." />) Second, img may not have a name. If you need Js to access it, use an ID instead. Same with forms, they may also not have a name="whatever" but instead id="whatever". Forms are block elements so maybe the validator is seeing it sitting in an inline element? Maybe that's why it's not allowed there? Third, target has been fully deprecated. Depending on what you want the form to do, you'll have to search teh Googles to replicate the intended effect without target. Now, you CAN get away with using target with transistional doctype like you have, so the validator won't say anything, but the point has been trying to move away from target as it's not accessible or too annoying or something... I dunno. Usually with links I can get away with no target anything as most users want and expect to go to a new page anyway, but with forms there's usually a good reason to keep the old page open (so the in-filler doesn't lose what they've already filled in), but like I said there are ways around this. Lastly, when you have more than one external Js file, it's my understanding that there are problems with loading... usually only the last-named script will load. So, I've been told by those who Js a lot is that you need to have an event handler in the <head> of the document. There is a site with such an event handler, if I can find it I'll post it. It will load each external script one at a time in the order you want. Hope this helps.
Uh, this isn't the one, but I think the event loader I was thinking of WAS at A List Apart... this is still useful: http://www.alistapart.com/articles/behavioralseparation
Ah, cheers lads finally got my page to validate as Xhtml 1.0 Transitional for now until i add some more gadgets on i guess! Seems it didnt like the form being inside a span, so i just changed the span to a div. Also the tips with the img tag did the trick, it's a shame these people produce invalidated code on their websites. The only problem now is with the javascript loading, which i did not have a problem until it was moved externally, the page freezes now for a good few seconds on this part of the page. Is there any way around this or not the code i'm using is: <script language="javascript" src="cc.js" type="text/javascript"></script> <a href="javascript:SLIDES.hotlink()"><img id="SLIDESIMG" src="x.jpg" style="filter:progid:DXImageTransform.Microsoft.Fade()" border="0" width="150px" height="150px" alt="Latest UK Bhangra Album Releases" class="floatright" /></a> <script language="javascript" src="dd.js" type="text/javascript"></script> Code (markup): This is for the rotating image script, if not i will use a different one i guess or remove it altogether. I wonder why it loads slowly externally? Many thanks for your help guys it's really appreciated, is there anyway i can help you out other than adding to your reputation?
Ah, yeah, a span is an inline element and can't hold block like forms. Div is a block and can hold other blocks and inlines. It may be the path to the external Js that's slowing it down... if it's in another folder on the server or something, it's taking time to go get that and load it... There's a way to have the Event Handler have it all pre-loaded or something... or even better, have that Javascript sitting on top of an image already, so you don't see the loading time. That's a plus as well since people without Js will see something in the spot too. And maybe you have to have the code commented out. //[ CDATA stuff stuff stuff ] // or something like that... I forget exactly. I'm never really clear on Js except that it shouldn't be sitting in the HTML (tho many people do it anyway). If all your HTML and CSS validate and the Js doesn't (since it's not HTML), then you could, if you wanted, leave it be. The validator doesn't know it's Js but the browsers with Js support do. If you can't stand the slowness, you could put it back in the HTML but that's just icky. I don't deal ever with Js so everything I know about it comes second or third hand. If it never gets fixed, there's a Js forum here I think (on Digital Point). Good luck.