Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   General Business Knowledge (http://www.greenguysboard.com/board/forumdisplay.php?f=10)
-   -   Doctype And Older Versions Of HTML (http://www.greenguysboard.com/board/showthread.php?t=67844)

ecchi 2016-02-09 04:51 AM

Doctype And Older Versions Of HTML
 
Can anyone explain why this works?

I used an online service to create a slideshow for my site. It worked on my Vista box, but on my XP box it only worked in Chrome, not in IE8. So I assumed it was in HTML5.

Today I was playing with the code with a view to (a) using it on other sites, and (b) making a version that worked on all browsers. I discovered the slider was entirely Javascript, so should work on IE8. Buggering about with it, I found that adding a doctype tag (doctype html) made it work. Why should this be? Why when everything else appears to work 100% OK without a declaration of doctype, should one Javascript piece of code require a doctype declaration?

Cleo 2016-02-09 08:26 AM

Doc type tells the engine in the browser how it should interpret the page.

ecchi 2016-02-09 04:24 PM

Yeah, sorry I wasn't clear. My question was "In that IE8 automatically assumes anything with a .html extension is a HTML document, why does it ignore certain javascript commands unless it is told the item is a HTML document in the document, by the doctype statement?"

Cleo 2016-02-09 04:36 PM

Because there is more than one kind of html doc and the doctype tells it what kind it is and what t do with its code.

The doctype control parsing of the page in order to display it correctly.
http://www.w3.org/QA/2002/04/valid-dtd-list.html

ecchi 2016-02-10 04:16 AM

Yes but without the declaration it processes most Javascript perfectly, so why not all Javascript? Also the declaration I am making does not tell it what version of HTML I'm using, I simply added:
Code:


Which basically says "I'm using some kind of html, but I'm not going to tell you what version - work it out for yourself", which the browser already knew from the .html file extension.

ecchi 2016-02-15 03:54 PM

I was given the answer over the weekend. If anyone wants to know:

It was not the Javascript, it was "div id=" which was the problem. Apparently IE8 knows some HTML commands that were not instigated when it was created, but had been mooted. If it is not fed a HTML type, it sticks strictly to the HTML that was official when it was released (which I think was HTML 3). However it takes "!DOCTYPE html" to mean "follow all HTML notification you know" so using this gets it to accept a few later HTML commands.


All times are GMT -4. The time now is 06:45 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc