KevinM1 Posted October 17, 2006 Share Posted October 17, 2006 I just found out (the hard way) that using innerHTML with XHTML produces a bug. While whatever one puts into innerHTML will appear on the screen, it won't be placed within the source code. This is a bit of a problem for me because my script (which is in an external file) relies on CSS (which is in another external file) classes for formatting. Since the code isn't really inserted into the XHTML, the script doesn't use the classes of the linked CSS file.I know there are createElement and appendChild methods. But I need to be able to write within the elements my script creates as well. Is there a way to do something like a document.write within my body element? Is write available for an element retrieved with a getElementByID? Quote Link to comment https://forums.phpfreaks.com/topic/24207-innerhtml-xhtml-bug/ Share on other sites More sharing options...
fenway Posted October 17, 2006 Share Posted October 17, 2006 I've never heard of this issue... and if you don't use an XHTML doctype, you're fine? Quote Link to comment https://forums.phpfreaks.com/topic/24207-innerhtml-xhtml-bug/#findComment-110128 Share on other sites More sharing options...
KevinM1 Posted October 17, 2006 Author Share Posted October 17, 2006 I just tried it without any XHTML references in the head and it's still doing the same thing. innerHTML should show whatever I have in it in the source, correct? Because right now it's only showing the empty body element that I used innerHTML to fill.EDIT: I have a copy of my XHTML at http://www.nightslyr.com/calendar/calendar2.htmlThe JavaScript can be found at http://www.nightslyr.com/calendar/calendar.jsThe CSS (which isn't working at this point because of my error) is at http://www.nightslyr.com/calendar/calendar.css Quote Link to comment https://forums.phpfreaks.com/topic/24207-innerhtml-xhtml-bug/#findComment-110137 Share on other sites More sharing options...
fenway Posted October 17, 2006 Share Posted October 17, 2006 What do you mean by "source code"? Where isn't it appearing? Quote Link to comment https://forums.phpfreaks.com/topic/24207-innerhtml-xhtml-bug/#findComment-110299 Share on other sites More sharing options...
KevinM1 Posted October 17, 2006 Author Share Posted October 17, 2006 [quote author=fenway link=topic=111769.msg453391#msg453391 date=1161123472]What do you mean by "source code"? Where isn't it appearing?[/quote]What I mean is this:I have a very simple XHTML page that literally only consists of an empty body element (well, there's the normal XHTML Strict head element goodies...).My script outputs the calendar, which are nested tables, as the innerHTML of the body element.When I try to view the XHTML source code from the browser, all it shows is my empty body element without any of the innerHTML stuff my script created within it.Is this normal? I thought that whatever was placed in innerHTML would be visible in the XHTML source if I looked at the source after the page was rendered. Quote Link to comment https://forums.phpfreaks.com/topic/24207-innerhtml-xhtml-bug/#findComment-110327 Share on other sites More sharing options...
tomfmason Posted October 18, 2006 Share Posted October 18, 2006 I don't think that I have ever seen the replaced html inside of the source code.. Take a look at a chat script that I am working on for a tutorial. http://www.thomashostings.net/chatTutorial.html . It is a bit buggy as of yet but you will see that I replace the message textarea with a login text input and button if you are not logged in. However, it never shows in the source. So I do not think that it is a rather serious issue. I have the xhtml doc type declared and I have no problem with the css or anything...Good Luck,Tom Quote Link to comment https://forums.phpfreaks.com/topic/24207-innerhtml-xhtml-bug/#findComment-110373 Share on other sites More sharing options...
KevinM1 Posted October 18, 2006 Author Share Posted October 18, 2006 Hmm....Well, that stinks. Looks like I'll have to code the tables directly into my markup. Quote Link to comment https://forums.phpfreaks.com/topic/24207-innerhtml-xhtml-bug/#findComment-110375 Share on other sites More sharing options...
tomfmason Posted October 18, 2006 Share Posted October 18, 2006 Why do you want the tables to be viewed in the source? I don't think that will really have any baring on what you are doing.. Tom Quote Link to comment https://forums.phpfreaks.com/topic/24207-innerhtml-xhtml-bug/#findComment-110379 Share on other sites More sharing options...
KevinM1 Posted October 18, 2006 Author Share Posted October 18, 2006 Well, this is all in relation to the calendar/appointment script I'm trying to make.Because I've been relying on an external script to print everything (tables and the data inside) using innerHTML, they're not 'seeing' my external CSS file. I figure that I can code the nested tables (one for the overall structure (3 months across by 4 months high), one for each calendar month) directly into the markup in order to ensure the CSS formatting works as a yearly calendar's overall structure will always remain the same (12 months to a year, at most 5 weeks/rows, depending on how late a month starts, a month). All that will change are the dates, which are derived by the script. Quote Link to comment https://forums.phpfreaks.com/topic/24207-innerhtml-xhtml-bug/#findComment-110439 Share on other sites More sharing options...
fenway Posted October 19, 2006 Share Posted October 19, 2006 That is strange... I've never really tested what happens to CSS attributes written out dynamically... Quote Link to comment https://forums.phpfreaks.com/topic/24207-innerhtml-xhtml-bug/#findComment-111396 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.