Maybe you can answer a question for me: I'm reading the preview for XML web development (sitepoint book) and it clearly shows IE rendering XML (the author states IE5 and above); does that mean that IE's problem with XHTML is CDATA and not XML universally? If that's true then IE could render an albeit gimped XHTML page which would explain why HTML 4.01 and XHTML are virtually synonymous in IE 6.
Is there a workaround for this in JavaScript, if the above is true?
I am trying to include and xml document inside my xhtml document. There are a number of reasons for this including portability, multiple interface generation, and scalability of information. My problem is that javascript is understanding the nodes in my xml document as html elements.
<xml> <book> <title>Lord of the Rings</title> </book> </xml>
If I parse this, the title element cannot be extracted and the page title(in the browser) becomes "Lord of the Rings". Is there a way to exclude this xml node from the xhtml rules?
I'm facing the bug about the failure of innterHTML while reading xhtml content inside a DIV, in fact it has passed as html removing the closing of some nodes. Is there a way to read the content of the div perfectly how it is in the page, kind of:
var obj = document.getElementById("myDIV"); var realContent = obj.toString();
IE6 in standards mode doesn't seem to hide scrollbars on the body element (overflow:hide) Ain't this a quandary. I have it in my head that I need to specify html instead. The scrollbars do hide on Gecko browsers though, so there is definitely a disagreement among browser developers on how to implement scrollbars (as a side note, Gecko browsers with their notoriously bug-ridden resize code seem to always screw up when asked to stretch and scroll divs, even when the page is reloaded on every resize!)
My first thought is to modify the CGI that generates the style sheet as I already have code that deprecates the document type when hidden scroll bars are required on IE6 (but not IE5.) This is based on the simple empirical evidence that the scroll bars are still there on IE6 in standards mode, so the optimal document type (XHTML strict) cannot be used. So I could just change this to output an html style (rather than a body style) for IE6 and lose the deprecation (it wouldn't be needed at this point.)
So the question is this. Given that CGI-based processing of browser versions for these kinds of tweaks is taboo, what would you check on the client side before dynamically generating the style for the body and/or html element? It doesn't seem like you could just send both as this would surely break some older browsers (I know you can do tricks with comments and such, but that only works for NS4 and maybe IE3 AFAIK.)
documentElement is the only thing I can think of that indicates standards mode and NS6/Mozilla support this AFAIK.
IE Conditional comments perhaps? I would hate to hard-code a test for a browser version number into the actual document (for obvious reasons), but I guess it is an alternative if the browser version is exposed to these things.
I don't see any other way to deal with a situation like this than with server-side code that looks at the browser's version number and makes the necessary adjustment. And there are lots of little differences like this that just don't seem to have viable client-only solutions. There's DirectX stuff (probably is an object detect for that) and funky colored scrollbars (hey people ask for them) and document margins (Opera did them slightly differently than the rest as I recall) and now this scrollbar thing.
There are two main things which I am trying to work through:
Drop down menu (bottom of page) - which only works in IE (on pc) right now, although it should work on all browsers except opera. Traditionally in a HTML 4.0 Transitional environment.
Div content that scrolls - placed correctly and works in IE and that's it. Here is an example of the working script on another site http://www.dyn-web.com/dhtml/scroll/scroll-rel.html . Traditionally in a Xhml strict.
My goal is to get this page to look as good in Netscape and on the mac as it already does in IE.
When using innerHTML to insert xhtml IE5+ mangles the xhtml completely. For example it removes the quotes from attributes. It also does other ridiculous things like on a <div> it will insert the enbedded style="DISPLAY:BLOCK"! This is a documented feature you can find in msdn.
Is there a way to disable this quite appalling feature?
I am trying to find a way to load XHTML content in an Iframe.
I use to do this in html by using the following code :
var iframeObject = document.createElement("iframe"); MyDiv.appendChild(iframeObject); var data = "<html><head><title>testing</title></head><body>data</body></html>" iframeObject.contentDocument.open(); iframeObject.contentDocument.writeln(data); iframeObject.contentDocument.close();
This works fine. I can create my content dynamicly and synchroniously. No problem.
No I try to switch to XHTML, but have trouble getting th eiframe to understand that it gets XHTML data. It simply assumes that the data is "text/html". I tried to add the contentType with the .open() arguments:
var iframeObject = document.createElement("iframe"); MyDiv.appendChild(iframeObject); var data = "<!DOCTYPE html PUBLIC "-//W3C//DTD ..etc.. transitional.dtd">" + "<html xmlns="http://www.w3.org/1999/xhtml" > etc etc </html>"; iframeObject.contentDocument.open("application/xhtml+xml", true); iframeObject.contentDocument.writeln(data); iframeObject.contentDocument.close();
The code runs but the content is not seen as xhtml, so I can't mix html and xml. Someone gave me the hint to use the following:
I try the following in Firefox and other modern browsers:
window.addEventListener('load', function() { document.title = CSS.getClass('fontSize'); var div = document.createElement('div'); document.getElementsByTagName('body')[0].appendChild(div); alert(div); alert(div.style) }, true);
It works fine in normal HTML mode (Content-type: text/html), but in XHTML mode it alerts "[object Element]" instead of "[object HTMLDivElement]" and the second alert shows "undefined" instead of "[object CSSStyleDeclaration]". So I can't reach the style declaration which is important for me. Strict mode makes trouble again and again, the biggest bug: document.write does not work:
I've just been converting my ASP v2.0 web site to use master pages which by default uses this doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
whereas before it used to use:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
This appears to have effected the multi-line textarea tag in that it doesn't completely obey the height attribute. It appears to adjust the height to the nearest line height.
Opera 7 doesn't appear to support the <script> element in XHTML. Does this mean that it impossible to use Javascript with XHTML? Or is there a workaround, such as the legacy method, in HTML, of commenting out the Javascript code.
this turns out to be a non-trivial exercise. inserting '<' and '>' causes the browser to write the text to the page as literal text rather than as the intended script element. Using escape codes seemed to work (makes it standard compliant) but the text is not written to the page.
The point is to have a conditional branch in which, when a certain condition is true, a script tag will be generated that will call a JS include that responds to the specific condition.
This procedure works in the present implementation -- but fails XHTML compliance testing. Now, we would like to have both.
I've been creating a script that dynamic loads js files.
but after creating that script, (and i use document.createElement('script');) in that function.. i've realise that the code that shows up in the browser is:
Thing is, when I do that, my whole layout messes up, it's as if it is ignoring my stylesheet when it is in the php version of the site, when it is in a normal html file, it pushes my main container to the left and then you can not see the header container properly, only a little bit of it. Everything seems to work fine if I keep it the code like the first shown here but I can not have it like that for xhtml, is there something I am missing here?
I have been attempting to transition to use of xhtml strict doctype andmy text editor, BBEdit (on Mac) tells me, when I ask it to check syntax,that the attribute 'name' is not allowed in form object, as in any otherform element that I tried to use it in. This begs the question, how doI script forms with javascript in the context of this doctype? None ofthe javascript texts I have address this issue (O'Reilly Rhino book andothers).I could figure it out, but it appears to be a complicated process, justdoing getElementById() and sorting it out.Does anyone have a reference to material that deals with this issue?
I've done my first public XHTML / CSS page, and it looks fine, but in IE6 there's an error message when the page is first loaded that says there's a syntax error in line 2. If I reload the page the error message disappears. I don't have an XML prolog, just
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
Why my script is working in an HTML 4.0 doc but not in XHTML. When I have it in XHTML and click the reset button it does reset the form but not the table. If I have it in HTML doc it resets both the table and the form.
Here is my code for the form (the part that is affected by the reset.)
This is for a class and they are requiring it to be XHTML..
I'm trying to move an image with the following JS function, but it only seems to work when I remove the XHTML doctype from the top of the document.
Here's the javascript:
Code:
I read something about this on another forum and I think it has something to do with the declaration of obj.style.top, but I can't find a solution. I've tried creating a new variable that contains "document.getElementByID(obj)" and then using that variable to change the top of the image, but it still doesn't work.
I'm considering in teaching myself some javascript, but before I take the time to read up and experiment, I had a few questions.
Is javascript XHTML 1.0 STRICT Valid? Is javascript valid for any version of XHTML? Is javascript easily cross browser compatiable, or will this take a long time to work around?
I am coding xhtml strict for my pages for the first time and I got some one problem with javascript:
I don't know how to modify the scripts to target elements on the page where the name attribute is deprecated.
Eg.
Code:
<form action="test.php" method="post"> <div><input name="text" /> <input type="submit" name="submit" value="search" /></div> </form> how can I modify the code to select such fild in such form ?
I am using a simple javascript image insertion on my XHTML page, and I have encountered a problem. The Javascript code fails to execute when the doctype is XHTML on Firefox (works on Opera). However, when I simply rename the file with an HTML extension, the code executes on all browsers. Code: