"document.getElementByld is null"

J

Jeremy J Starcher

According to friends of mine who use MSIE, the following page
http://tinyurl.com/3crkar

Please do not use tinyurl.
http://gojomo.blogspot.com/2006/02/tinyurls-are-evil-urls.html
Error: 'document.getElementByld[...]' is null or not an object

Valid your web page against HTML 4.01 strict

No version of IE currently supports XHTML.

Even if IE did, this line would cause you all sorts of grief
<script type="text/javascript"><!--//--><![CDATA[//><!--

HTML 4.01 strict does not require the HTML comments nor the CDATA blocks.

It works (almost) all right in Firefox. Any clue ?

Yup. Your page is broken.
 
V

VK

According to friends of mine who use MSIE, the following pagehttp://tinyurl.com/3crkar
returns ajavascript error :
Error: 'document.getElementByld[...]' is null or not an object

It works (almost) all right in Firefox.
Any clue ?

Thank you,

Martin (french)

Currently I cannot load your page into IE6 at all: it reports "Page
cannot be loaded" or displays empty gray background. Are you using
application/xhtml+xml content type? If so then you cannot do it unless
making "non-IE only" site: XHTML is not supported by IE. Ensure first
that the pages are served as text/html, then let's look for further
problems is any remain.
 
M

martin

VK a écrit :
Currently I cannot load your page into IE6 at all: it reports "Page
cannot be loaded" or displays empty gray background. Are you using
application/xhtml+xml content type? If so then you cannot do it unless
making "non-IE only" site: XHTML is not supported by IE. Ensure first
that the pages are served as text/html, then let's look for further
problems is any remain.

It's quite a surprise for me, I run a few websites built with a CMS
called SPIP, and they behave allright in MSIE, although they state at
the top of every page :

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
 
J

Jeremy J Starcher

That's a clear answer. Thank you :)

The details about HOW it was broken were above in the comments about the
XHTML.

Many (most?) folks here believe that having the page validate properly is
the first step in Javascript debugging.

Under IE, XHTML is broken.
http://www.hixie.ch/advocacy/xhtml

Didn't mean it as a snide comment. Until the page validates to HTML
4.01, the was the best and most detailed answer I could give.
 
J

Jeremy J Starcher

It's quite a surprise for me, I run a few websites built with a CMS
called SPIP, and they behave allright in MSIE, although they state at
the top of every page :

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>

IE will render these pages as "tag-soup" -- that is, it will render them
the same way it will render any other badly formed page. By "best-
guessing" what the author meant. The best-guest is not always right.
 
V

VK

It's quite a surprise for me, I run a few websites built with a CMS
called SPIP, and they behave allright in MSIE, although they state at
the top of every page :

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>

I am not talking about DOCTYPE, I am talking about Content-type in
server response header. It must be text/html and nothing else - again
unless you want to prohibit IE6/IE7 users from viewing your site.
DOCTYPE is irrelevant to the document treatment (HTML vs. XHTML), only
Content-type is regarded by browsers.

So first make sure that the server serves all pages as Content-type:
text/html

Then let's look further if any JavaScript problems are.
 
M

martin

VK a écrit :
So first make sure that the server serves all pages as Content-type:
text/html

I've been trying for a couple of hours to understand what's happening,
but I have a problem.
(sorry, possible broken english in what follows)

What seems to create the problem is a call to a js function called
overlibmws

Here is a small part of the code :

<area shape="poly" coords="2,80,40" href="javascript:void(0)"
onclick="return overlib('<div class=\'ovfl\'><img
src=\'IMG/arton370.jpg\' width=\'60\' height=\'80\' />here I have some
text<br/>text again<br class=\'nettoyeur\' </div>');" />

Apparently, when parsing my html file, the validator is horrified by
those <div> that shouldn't be here.

So my question could be reformulated as
"do you know how to insert html properly code between the brackets of
return overlib();
?
 
S

SAM

martin a écrit :
Apparently, when parsing my html file, the validator is horrified by
those <div> that shouldn't be here.

So my question could be reformulated as
"do you know how to insert html properly code between the brackets of
return overlib();

try something like :

<area shape="poly" coords="2,80,40" href="javascript:void(0)"
onclick="return overlib('<'+'div class=\'ovfl\'><img
src=\'IMG/arton370.jpg\' width=\'60\' height=\'80\' />here I have some
text<br/>text again<br class=\'nettoyeur\' <'+'/div'+'>');" />

Are you sure you need overlib with an onclick ?
 
M

martin

SAM a écrit :
try something like :

<area shape="poly" coords="2,80,40" href="javascript:void(0)"
onclick="return overlib('<'+'div class=\'ovfl\'><img
src=\'IMG/arton370.jpg\' width=\'60\' height=\'80\' />here I have some
text<br/>text again<br class=\'nettoyeur\' <'+'/div'+'>');" />

I tried that, and it stills looks OK in Firefox.
But the W3C validator keeps telling me that

"character '<' is the first character of a delimiter but occurred as data."

I got hundreds like this one :)
Are you sure you need overlib with an onclick ?

This is a good question. I intended to do something like this :

http://www.unsa.org/?page=carte

And it's the easiest way I found...
 
S

SAM

martin a écrit :
SAM a écrit :
I tried that, and it stills looks OK in Firefox.
But the W3C validator keeps telling me that

"character '<' is the first character of a delimiter but occurred as data."

I got hundreds like this one :)

You can try replacing '<' by '&lt' but I don't know what overlib will do
with that.

You can also use (and it is always preferable)
a separate JS code (in the header or in a file)

var I = [];
I[0] = '<div ... blah 1 ... >';
I[1] = '<div ... blah 1 ... >';
I[2] = '<div ... blah 1 ... >';

function pop(i) { overlib(I); return false; }

and in your map

<area href="#" onclick="return pop(0);" coord=" ..." tiltel="Allier">
<area href="#" onclick="return pop(1);" coord=" ..." title="Ain">

For your convenience you could also do :

var I = [];
I['Allier'] = '<div ... blah 1 ... >';
I['Ain'] = '<div ... blah 1 ... >';
I['Aines'] = '<div ... blah 1 ... >';

function pop(x) { overlib(I[x]); return false; }

and in your map

<area href="#" coord=" ..."
onclick="return pop('Allier');" tiltel="Allier">
<area href="#" coord=" ..."
onclick="return pop('Ain');" title="Ain">
I intended to do something like this :
http://www.unsa.org/?page=carte

Ha! oui ! pas mal.
Mais mon Fx me dit :
"Result: 0 erreurs / 91 avertissements"
Il faut juste savoir si le Validator est une priorité ?
 
D

David Mark

SAM a écrit :



I tried that, and it stills looks OK in Firefox.
But the W3C validator keeps telling me that

"character '<' is the first character of a delimiter but occurred as data."

I got hundreds like this one :)

You are using XHTML. Inline script should be enclosed in a CDATA
section. Of course, you aren't serving it as XHTML, so you will have
to hide the CDATA delimiters with JavaScript comments. It would make
more sense to use HTML.

As for your script error, there is really no telling as you are using
a combination of two of the worst libraries around (jQuery and
Overlib.) Get rid of them if you want a reliable site.
 
M

martin

SAM a écrit :
You can try replacing '<' by '&lt' but I don't know what overlib will do
with that.

I found this page
http://gougeyoureyesout.com/cssFun/2006/10/escaping-html-character-entities-in.html

and I replaced '<' with '\&lt;' : it seems to work (it means the
validator finds 150 errors instead of 300 :)
You can also use (and it is always preferable)
a separate JS code (in the header or in a file)

I'll try that, too.
Ha! oui ! pas mal.
Mais mon Fx me dit :
"Result: 0 erreurs / 91 avertissements"
Il faut juste savoir si le Validator est une priorité ?

You're right, they fail validation, too. But they look OK in MSIE
anyway, so it would be sufficient for me (oops, hope I won't be
lapidated for saying this here :)
 
M

martin

David Mark a écrit / wrote :
You are using XHTML. Inline script should be enclosed in a CDATA
section. Of course, you aren't serving it as XHTML, so you will have
to hide the CDATA delimiters with JavaScript comments. It would make
more sense to use HTML.

Unfortunately I use a CMS that serves XHTML, so I can't really change
that (to me more honest I don't know if it's possible and how to do that).
As for your script error, there is really no telling as you are using
a combination of two of the worst libraries around (jQuery and
Overlib.) Get rid of them if you want a reliable site.

I'd like to, but do you have any replacement solution for a newbie like
me to obtain something like this clickable map ?

http://www.unsa.org/?page=carte

I could do that in Flash, but I'm not sure it's a good idea...
 
S

SAM

martin a écrit :
David Mark a écrit / wrote :


Unfortunately I use a CMS that serves XHTML, so I can't really change
that (to me more honest I don't know if it's possible and how to do that).


I'd like to, but do you have any replacement solution for a newbie like
me to obtain something like this clickable map ?

I think that in XHTML (strict ?) you're not allowed to have onclick
attribute in your html code.

If you have acces to the the built of the page, prefer to introduce the
JS code in its header and to attribute from there the events to your areas

var A = document.getElementsByTagName('area');
for(var i=0, n=A.length; i<n; i++) {
A.ref = i;
A.onclick = function() { return pop(this.ref); };
}
http://www.unsa.org/?page=carte

I could do that in Flash, but I'm not sure it's a good idea...

en effet !
 
V

VK

I am not talking about DOCTYPE, I am talking about Content-type in
That is not true with regards to Safari on Windows.

It is not? Cool and very helpful for a wide run :)
You know, in order to surprise me, Safari team has to try harder now,
say to cause brain damage by some pre-programmed emanation: or say
have 1Gb hidden game pack. All more-or-less obvious strange, dumb,
silly, idiotic and other things and errors they are doing since 1.x

Safari is another splendid proof that the first browser user sees on
the desktop is the winner no matter how ugly it is. And to win over
the most ugly yet first seen browser, the competitor has to be not
just much better, but damn better and still fighting for the
attention.
 
D

David Mark

VK said the following on 1/12/2008 3:14 PM:



<URL:http://groups.google.com/group/comp.lang.javascript/browse_thread/thr....>

Try testing it. It goes by the file extension.

All of them do that locally.
Never tested the above from a server, it may not behave the same way
when served with a Header. I think, personally, that it was a failed

It doesn't.
attempt to deal with the XHTML vs. HTML issue on the web.

It is just the typical desktop application behavior. In this case,
the XHTML extension is mapped to a MIME type in the registry (as well
as a default application.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top