Script validation = BAD

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Code: [ Select ]
new_window.document.write('<p>Why do we require such information from you?</p>');
new_window.document.write("<p>The main reason would be for varification of legitimacy of users who get to use this site.</p>");
new_window.document.write("<p>If you feel violated by the requiring and feel that a question could be left out unrequired than you can contact the

administrator and tell the administrator about it</p>");
new_window.document.write("<p>If there is any other questions concerning either the registration or whatever content inside the registration, contact the

administrator and ask your question to the administrator.</p>");
new_window.document.write("<p>You don't have to register to this site. Registering to this site merely opens new features for users to use.</p>");
  1. new_window.document.write('<p>Why do we require such information from you?</p>');
  2. new_window.document.write("<p>The main reason would be for varification of legitimacy of users who get to use this site.</p>");
  3. new_window.document.write("<p>If you feel violated by the requiring and feel that a question could be left out unrequired than you can contact the
  4. administrator and tell the administrator about it</p>");
  5. new_window.document.write("<p>If there is any other questions concerning either the registration or whatever content inside the registration, contact the
  6. administrator and ask your question to the administrator.</p>");
  7. new_window.document.write("<p>You don't have to register to this site. Registering to this site merely opens new features for users to use.</p>");


I can't get that script to validate. validator.w3.org says that the <p>...</p> is not supposed to be there, and if I remove them then the content looks messed up. If you need the whole thing here it is...

Code: [ Select ]
<script type="text/javascript">
// This is the function that will open the
// new window when the mouse is moved over the link
function open_new_window()
{
new_window = open("","hoverwindow","width=300,height=500,left=10,top=10");

// open new document
new_window.document.open();

// Text of the new document
// Replace your " with ' or \" or your document.write statements will fail

new_window.document.write('<p>Why do we require such information from you?</p>');
new_window.document.write("<p>The main reason would be for varification of legitimacy of users who get to use this site.</p>");
new_window.document.write("<p>If you feel violated by the requiring and feel that a question could be left out unrequired than you can contact the

administrator and tell the administrator about it</p>");
new_window.document.write("<p>If there is any other questions concerning either the registration or whatever content inside the registration, contact the

administrator and ask your question to the administrator.</p>");
new_window.document.write("<p>You don't have to register to this site. Registering to this site merely opens new features for users to use.</p>");
// close the document
new_window.document.close();
}

// This is the function that will close the
// new window when the mouse is moved off the link
function close_window()
{
new_window.close();
}

-->
</script>
<div class="addt" onmouseover="open_new_window()" onmouseout="close_window()"><p>(*) = Required</p>
  1. <script type="text/javascript">
  2. // This is the function that will open the
  3. // new window when the mouse is moved over the link
  4. function open_new_window()
  5. {
  6. new_window = open("","hoverwindow","width=300,height=500,left=10,top=10");
  7. // open new document
  8. new_window.document.open();
  9. // Text of the new document
  10. // Replace your " with ' or \" or your document.write statements will fail
  11. new_window.document.write('<p>Why do we require such information from you?</p>');
  12. new_window.document.write("<p>The main reason would be for varification of legitimacy of users who get to use this site.</p>");
  13. new_window.document.write("<p>If you feel violated by the requiring and feel that a question could be left out unrequired than you can contact the
  14. administrator and tell the administrator about it</p>");
  15. new_window.document.write("<p>If there is any other questions concerning either the registration or whatever content inside the registration, contact the
  16. administrator and ask your question to the administrator.</p>");
  17. new_window.document.write("<p>You don't have to register to this site. Registering to this site merely opens new features for users to use.</p>");
  18. // close the document
  19. new_window.document.close();
  20. }
  21. // This is the function that will close the
  22. // new window when the mouse is moved off the link
  23. function close_window()
  24. {
  25. new_window.close();
  26. }
  27. -->
  28. </script>
  29. <div class="addt" onmouseover="open_new_window()" onmouseout="close_window()"><p>(*) = Required</p>


It just opens another window onmouseover event and closes it onmouseout event. If there is another alternative for it (which can validate and work on more than one link with each pop-up window with different content in them).

Any help would be greatly appreciated.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Quote:
<!-- script statements, which may include CDATA sections -->
<!ELEMENT script (#PCDATA)>


What is happening, is that the script text itself is being considered as TEXT nodes.
When it comes across the <p> elements in your script, is assumes that they're child elements of your <script> element, & since <script> elements aren't supposed to have childnodes other than TEXT or PCDATA (which is basicly TEXT), it assumes that <p> element is an error.

You need to tell the parser not to do that, & to treat the content of that <script> element as a single child node, you do that with <![CDATA]]>

Code: [ Select ]
<script type="text/javascript"><![CDATA[

...

]]></script>
  1. <script type="text/javascript"><![CDATA[
  2. ...
  3. ]]></script>


The parser will ignore scripted elements inside a CDATA container & treat it as a single childNode with a nodeValue.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Awesome! Thank you joebert. That helped.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Also, another problem...

http://validator.w3.org wrote:
Image Line 153, Column 101: element "u" undefined.
Quote:
…. They are used in a singular form <u>always</u> with no "s" or "es" added an

You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by:

* incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element),
* by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead).
* by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case).
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

If you're using XHTML-strict, the underline (u) element isn't available in that DOCTYPE, use XHTML-transitional instead.

Here's the available elements for XHTML-strict
Code: [ Select ]
<!ELEMENT html (head, body)>
<!ELEMENT head (%head.misc;,
   ((title, %head.misc;, (base, %head.misc;)?) |
   (base, %head.misc;, (title, %head.misc;))))>
<!ELEMENT title (#PCDATA)>
<!ELEMENT base EMPTY>
<!ELEMENT meta EMPTY>
<!ELEMENT link EMPTY>
<!ELEMENT style (#PCDATA)>
<!ELEMENT script (#PCDATA)>
<!ELEMENT noscript %Block;>
<!ELEMENT body %Block;>
<!ELEMENT div %Flow;> <!-- generic language/style container -->
<!ELEMENT p %Inline;>
<!ELEMENT h1 %Inline;>
<!ELEMENT h2 %Inline;>
<!ELEMENT h3 %Inline;>
<!ELEMENT h4 %Inline;>
<!ELEMENT h5 %Inline;>
<!ELEMENT h6 %Inline;>
<!ELEMENT ul (li)+>
<!ELEMENT ol (li)+>
<!ELEMENT li %Flow;>
<!ELEMENT dl (dt|dd)+>
<!ELEMENT dt %Inline;>
<!ELEMENT dd %Flow;>
<!ELEMENT address %Inline;>
<!ELEMENT hr EMPTY>
<!ELEMENT pre %pre.content;>
<!ELEMENT blockquote %Block;>
<!ELEMENT ins %Flow;>
<!ELEMENT del %Flow;>
<!ELEMENT a %a.content;>
<!ELEMENT span %Inline;> <!-- generic language/style container -->
<!ELEMENT bdo %Inline;> <!-- I18N BiDi over-ride -->
<!ELEMENT br EMPTY>  <!-- forced line break -->
<!ELEMENT em %Inline;>  <!-- emphasis -->
<!ELEMENT strong %Inline;>  <!-- strong emphasis -->
<!ELEMENT dfn %Inline;>  <!-- definitional -->
<!ELEMENT code %Inline;>  <!-- program code -->
<!ELEMENT samp %Inline;>  <!-- sample -->
<!ELEMENT kbd %Inline;> <!-- something user would type -->
<!ELEMENT var %Inline;>  <!-- variable -->
<!ELEMENT cite %Inline;>  <!-- citation -->
<!ELEMENT abbr %Inline;>  <!-- abbreviation -->
<!ELEMENT acronym %Inline;>  <!-- acronym -->
<!ELEMENT q %Inline;>  <!-- inlined quote -->
<!ELEMENT sub %Inline;> <!-- subscript -->
<!ELEMENT sup %Inline;> <!-- superscript -->
<!ELEMENT tt %Inline;>  <!-- fixed pitch font -->
<!ELEMENT i %Inline;>  <!-- italic font -->
<!ELEMENT b %Inline;>  <!-- bold font -->
<!ELEMENT big %Inline;>  <!-- bigger font -->
<!ELEMENT small %Inline;>  <!-- smaller font -->
<!ELEMENT object (#PCDATA | param | %block; | form | %inline; | %misc;)*>
<!ELEMENT param EMPTY>
<!ELEMENT img EMPTY>
<!ELEMENT map ((%block; | form | %misc;)+ | area+)>
<!ELEMENT area EMPTY>
<!ELEMENT form %form.content;>  <!-- forms shouldn't be nested -->
<!ELEMENT label %Inline;>
<!ELEMENT input EMPTY>   <!-- form control -->
<!ELEMENT select (optgroup|option)+> <!-- option selector -->
<!ELEMENT optgroup (option)+>  <!-- option group -->
<!ELEMENT option (#PCDATA)>   <!-- selectable choice -->
<!ELEMENT textarea (#PCDATA)>   <!-- multi-line text field -->
<!ELEMENT fieldset (#PCDATA | legend | %block; | form | %inline; | %misc;)*>
<!ELEMENT legend %Inline;>   <!-- fieldset label -->
<!ELEMENT button %button.content;> <!-- push button -->
<!ELEMENT table (caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))>
<!ELEMENT caption %Inline;>
<!ELEMENT thead  (tr)+>
<!ELEMENT tfoot  (tr)+>
<!ELEMENT tbody  (tr)+>
<!ELEMENT colgroup (col)*>
<!ELEMENT col   EMPTY>
<!ELEMENT tr    (th|td)+>
<!ELEMENT th    %Flow;>
<!ELEMENT td    %Flow;>
  1. <!ELEMENT html (head, body)>
  2. <!ELEMENT head (%head.misc;,
  3.    ((title, %head.misc;, (base, %head.misc;)?) |
  4.    (base, %head.misc;, (title, %head.misc;))))>
  5. <!ELEMENT title (#PCDATA)>
  6. <!ELEMENT base EMPTY>
  7. <!ELEMENT meta EMPTY>
  8. <!ELEMENT link EMPTY>
  9. <!ELEMENT style (#PCDATA)>
  10. <!ELEMENT script (#PCDATA)>
  11. <!ELEMENT noscript %Block;>
  12. <!ELEMENT body %Block;>
  13. <!ELEMENT div %Flow;> <!-- generic language/style container -->
  14. <!ELEMENT p %Inline;>
  15. <!ELEMENT h1 %Inline;>
  16. <!ELEMENT h2 %Inline;>
  17. <!ELEMENT h3 %Inline;>
  18. <!ELEMENT h4 %Inline;>
  19. <!ELEMENT h5 %Inline;>
  20. <!ELEMENT h6 %Inline;>
  21. <!ELEMENT ul (li)+>
  22. <!ELEMENT ol (li)+>
  23. <!ELEMENT li %Flow;>
  24. <!ELEMENT dl (dt|dd)+>
  25. <!ELEMENT dt %Inline;>
  26. <!ELEMENT dd %Flow;>
  27. <!ELEMENT address %Inline;>
  28. <!ELEMENT hr EMPTY>
  29. <!ELEMENT pre %pre.content;>
  30. <!ELEMENT blockquote %Block;>
  31. <!ELEMENT ins %Flow;>
  32. <!ELEMENT del %Flow;>
  33. <!ELEMENT a %a.content;>
  34. <!ELEMENT span %Inline;> <!-- generic language/style container -->
  35. <!ELEMENT bdo %Inline;> <!-- I18N BiDi over-ride -->
  36. <!ELEMENT br EMPTY>  <!-- forced line break -->
  37. <!ELEMENT em %Inline;>  <!-- emphasis -->
  38. <!ELEMENT strong %Inline;>  <!-- strong emphasis -->
  39. <!ELEMENT dfn %Inline;>  <!-- definitional -->
  40. <!ELEMENT code %Inline;>  <!-- program code -->
  41. <!ELEMENT samp %Inline;>  <!-- sample -->
  42. <!ELEMENT kbd %Inline;> <!-- something user would type -->
  43. <!ELEMENT var %Inline;>  <!-- variable -->
  44. <!ELEMENT cite %Inline;>  <!-- citation -->
  45. <!ELEMENT abbr %Inline;>  <!-- abbreviation -->
  46. <!ELEMENT acronym %Inline;>  <!-- acronym -->
  47. <!ELEMENT q %Inline;>  <!-- inlined quote -->
  48. <!ELEMENT sub %Inline;> <!-- subscript -->
  49. <!ELEMENT sup %Inline;> <!-- superscript -->
  50. <!ELEMENT tt %Inline;>  <!-- fixed pitch font -->
  51. <!ELEMENT i %Inline;>  <!-- italic font -->
  52. <!ELEMENT b %Inline;>  <!-- bold font -->
  53. <!ELEMENT big %Inline;>  <!-- bigger font -->
  54. <!ELEMENT small %Inline;>  <!-- smaller font -->
  55. <!ELEMENT object (#PCDATA | param | %block; | form | %inline; | %misc;)*>
  56. <!ELEMENT param EMPTY>
  57. <!ELEMENT img EMPTY>
  58. <!ELEMENT map ((%block; | form | %misc;)+ | area+)>
  59. <!ELEMENT area EMPTY>
  60. <!ELEMENT form %form.content;>  <!-- forms shouldn't be nested -->
  61. <!ELEMENT label %Inline;>
  62. <!ELEMENT input EMPTY>   <!-- form control -->
  63. <!ELEMENT select (optgroup|option)+> <!-- option selector -->
  64. <!ELEMENT optgroup (option)+>  <!-- option group -->
  65. <!ELEMENT option (#PCDATA)>   <!-- selectable choice -->
  66. <!ELEMENT textarea (#PCDATA)>   <!-- multi-line text field -->
  67. <!ELEMENT fieldset (#PCDATA | legend | %block; | form | %inline; | %misc;)*>
  68. <!ELEMENT legend %Inline;>   <!-- fieldset label -->
  69. <!ELEMENT button %button.content;> <!-- push button -->
  70. <!ELEMENT table (caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))>
  71. <!ELEMENT caption %Inline;>
  72. <!ELEMENT thead  (tr)+>
  73. <!ELEMENT tfoot  (tr)+>
  74. <!ELEMENT tbody  (tr)+>
  75. <!ELEMENT colgroup (col)*>
  76. <!ELEMENT col   EMPTY>
  77. <!ELEMENT tr    (th|td)+>
  78. <!ELEMENT th    %Flow;>
  79. <!ELEMENT td    %Flow;>
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

I want to keep it XHTML Strict... is there any CSS equivalent of underline?
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

text-decoration
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

:lol: I should have known lol
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa

Post 3+ Months Ago

I know this is already sorted basically, just a sidenote

Bogey wrote:
Code: [ Select ]
new_window.document.write('<p>Why do we require such information from you?</p>');
new_window.document.write("<p>The main reason would be for varification of legitimacy of users who get
  1. new_window.document.write('<p>Why do we require such information from you?</p>');
  2. new_window.document.write("<p>The main reason would be for varification of legitimacy of users who get



With the top one you're using single quotes (') and with the bottom one normal/double quotes(") ...
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

... yeah, I know... forgot about that. Gotta change that. Thanks for pointing it out.
  • claireo
  • Beginner
  • Beginner
  • claireo
  • Posts: 62
  • Loc: Coventry

Post 3+ Months Ago

If you change your body text to the same as your <p> text then this will allow you to take out the <p> tags and it stay in the style you want.

Claire
//link removed. Please use the signature option in the control panel for your links
Moderator Remark: Removed link in post.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

oh, and by the way joebert... thanks for that list of available xhtml script elements... kind of late :lol:
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

If you found that list usefull, you could read this tutorial.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

joebert wrote:
If you found that list usefull, you could read this tutorial.


Thanks, I'll look into it

Post Information

  • Total Posts in this topic: 14 posts
  • Users browsing this forum: No registered users and 52 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.