homepage Welcome to WebmasterWorld Guest from 54.196.62.23
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
writing tags with javascript in xhtml
doesn't validate
mfagan

10+ Year Member



 
Msg#: 219 posted 3:23 am on Oct 31, 2002 (gmt 0)

I am using the javascript statement
document.write("<tag name='foo'>stuff</tag>")
and when I try to validate I get the error "Error: element "tag" not allowed here; check which elements this element may be contained within"

Any suggestions? (yes, I guess I could put it in an external js file)

Also, it seems that javascript events aren't allowed in xhtml, such as <form onSubmit="dostuff()"> . What should I be doing instead?

 

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 219 posted 6:11 am on Oct 31, 2002 (gmt 0)

<script type="text/javascript">//<![cdata[ 
alert('hello');
//]]>--></script>

dingman

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 219 posted 6:34 am on Oct 31, 2002 (gmt 0)

Also, it seems that javascript events aren't allowed in xhtml, such as <form onSubmit="dostuff()"> . What should I be doing instead?

Do like Andreas said, then convert all your event attributes to all-lowercase. (i.e., <form onsubmit="dostuff();">) Then the validator will like you. (Or at least your page :))

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 219 posted 10:26 pm on Dec 11, 2002 (gmt 0)

Don't forget to include both the opening <!-- and closing // --> comment tags, also noting that there must be a space after the opening comment, and another before the closing comment.

Any closing </bar> will "fool" the validator, and give an error. Closing tags within document.write statements need to be broken in two, in order to hide them from the validator, like "</" + "bar>" and so on.

Make sure that the element that you are including with the document.write is valid in that place in the HTML structure; that you are not trying to nest an element where it is not allowed.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved