JS quote problem & # 145

liunx

Guest
Hi,<br />
<br />
After running my script through W3C's validator, I came up with the following errors:<br />
<br />
<br />
Line 15, column 53: <br />
<script language="JavaScript" src=http://www.htmlforums.com/archive/index.php/"js2002/overlib.js"><br />
^<br />
Error: required attribute "TYPE" not specified <br />
<br />
Should it be type="text/js"? *guess*<br />
<br />
and the second error was:<br />
<br />
<br />
Line 54, column 50: <br />
... 7. "And lo a voice from Heaven, saying, &#145 This is My beloved S ...<br />
^<br />
Error: reference to non-SGML character (single quote)<br />
<br />
<br />
What else would that single quote & # 145 be written as?<br />
<br />
Thanks, Gandalf<br />
:D<!--content-->Try & # 145 ; In other words with the semi-colon at the end. (Obviously you scrunch it all back together again to get it to work - I'm surprised that it defeated the [ code ] tag.)<br />
<br />
Neil<!--content--><script language="javascript" type="text/javascript"><br />
<br />
& # 145 ;<br />
(without spaced in between).<!--content--><script language="javascript" type="text/javascript" src=http://www.htmlforums.com/archive/index.php/"js2002/overlib.js"><br />
<br />
That is correct, but this attribute seems to be missing from about 99% of all the JavaScript tutorials on the web, as well as most of the examples given on HTML Forums. It bugs me that most of the examples and tutorials on the net are incomplete. It seems that the Javascript programmers are whizz-kids at Javascript, but have little idea how to integrate their code back into the HTML without breaking the HTML standards.<br />
<br />
<br />
<br />
The &#145; problem is that this character is one of the Smart Quotes. These are quote marks that curl in depending on which side of the word they are placed. I think that &#146; is the other one (from memory). I guess that this HTML code comes from a page written in Microsoft Word, Publisher or Frontpage. You should just use a Standard Quote Mark in place of this code. Edit the page source code in a simple Text Editor to correct the 'problem'.<br />
<br />
[By the way, the way to write an escaped code like &#145; on a forum is to write the & as &amp; in the edit screen. You have to escape the ampersand before you can write the rest of the escaped code. So if you write &amp;#145; in the edit screen, it will then show as &#145; on the public view. In other words, whatever escaped code you want to show, you need to include one more amp; immediately after the & in the source compared to what you want to show on the public side of the forum].<!--content-->because a lie is told a 1000 times does not make it right, or in this case, because an attribute is omitted a 1000 times does not make it right. The standards call for use of the type attribute (the language attribute is depreciated, but can be used for now to ensure cross browser compliance).<br />
<br />
I am not terribly fuzzy about use the type attribute, but if you are going to validate your code, then use the type attribute, but don't forget about the language attribute just yet because most legancy browsers require it. That being said, if you just type <script> then most browsers just default to javascript (or jscript), but it is good programming to use as minimum the type property.<br />
<br />
Thanks for the advise on using special characters..<br />
&#145; gives this result --> ‘ <br />
:D<!--content-->Well, the JS type worked; however, not the single quote.<br />
<br />
<br />
Line 54, column 50: <br />
... 7. "And lo a voice from Heaven, saying, ‘ [&#145;]This is My beloved ...<br />
^<br />
Error: reference to non-SGML character <br />
<br />
<br />
As you will notice above I have added the semi-colon and revalidated it, but still doesn't work.<br />
<br />
Maybe this will help, because of the single quotes that already exist, this is the only way I know of to get around the problem:<br />
<br />
<br />
<a href=http://www.htmlforums.com/archive/index.php/"javascript:void(0);" onmouseover="return overlib('17. "And lo a voice from Heaven, saying, ‘ [&#145;]This is My ...’ [&#146;]"');" onmouseout="return nd();">LINK</a><br />
<br />
<br />
Suggestions?<br />
Gandalf<br />
:D<!--content-->The &#145; and &#146; are Microsoft Smart Quotes. These are not valid SGML characters and should not be used.<br />
<br />
Use a non-Microsoft product, some sort of text editor, to change these into regular single quotes. You will see that Smart Quotes are ones that curl in depending on which side of the word they are placed. You do not need to use encoding, just a regular non-curly non-smart quote mark.<!--content-->
 
Back
Top