By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

xhtml and javascript in opera - help me please

P: n/a
Hi,

I created a page with xhtml 1.0 transitional dtd, its validated
correctly, but now the javascript wouldn't work under Opera (version
8.5 I think). It works under firefox.

My code is as follow:

<?xml version="1.0" encoding="UTF-8"?>
<!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">
<head>
<meta http-equiv="Content-Type"
content="application/xhtml+xml;charset=UTF-8" />
<title>My title</title>
<script type="text/javascript" src="formlib.js"></script>
<script type="text/javascript" src="sarissa/sarissa.js"></script>
<script type="text/javascript">
<![CDATA[

window.onload = body_onload;
if (window.captureEvents) window.captureEvents(Event.LOAD);

function body_onload()
{
register_event("change", get_field_object("city"),
field_city_onchange );
register_event("change", get_field_object("area"),
field_area_onchange );
register_event("change", get_field_object("suburbOpt"),
field_suburbOpt_onchange );
register_event("submit", document.forms["search"],
form_search_onsubmit );

_suburbs_disabled_or_enabled();
}
// ]]>
</script>
....

Note: I really do need to have the javascript code in the page, not
through external files because these codes are dynamically generated by
server side scripts.

The page was working under firefox/Opera/IE before I added Doctype on
top of the page.

Mar 20 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a


Crazy Code Ninja wrote:

I created a page with xhtml 1.0 transitional dtd, its validated
correctly, but now the javascript wouldn't work under Opera (version
8.5 I think). It works under firefox.

My code is as follow:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


Do you serve the XHTML as text/html or do you serve it has
application/xhtml+xml? Does the Opera JavaScript console show any
errors? Can you post a URL where the proplem occurs?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 21 '06 #2

P: n/a
My apology, it was a javascript error, the reason I didn't suspect it
was because Opera didn't show any javascript error in the console. But
I ran it in IE and found the error, fixed it, and now its running fine
in firefox/ie/opera :-)

And I changed it to valid xhtml 1.0 strict and serve it as xml or just
html depending on whether the browser support it:

<?
if (isset($_SERVER["HTTP_ACCEPT"]) &&
stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml"))
{
$bl_content_type = "application/xhtml+xml";
header("Content-Type: $bl_content_type");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
}
else
{
$bl_content_type = "text/html";
header("Content-Type: $bl_content_type");
}
?>

Kind Regards

Sid

Mar 21 '06 #3

P: n/a
Crazy Code Ninja wrote:
And I changed it to valid xhtml 1.0 strict and serve it as xml or just
html depending on whether the browser support it:

<?
if (isset($_SERVER["HTTP_ACCEPT"]) &&
stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml"))


Maybe the browser supports but does not prefer it. Hint: quality values.

--
Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
(Thomas Tallis, 40-part motet)
Mar 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.