473,623 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XHTML DOCTYPE breaks JavaScript x.style.top and x.style.left?

I have the following script (below). If I have the DOCYPE at the top,
tDIV.style.top and tDIV.style.left don't return a value. If I remove the
DOCTYPE from the first line, it works fine and returns and manipulates the
values perfectly.

What could possibly be the relationship? Why would the inclusion of a
DOCTYPE tag at the top of a page break Javascript code?

Browser: Mozilla Firefox. (note: the DOCTYPE on my site is all on one
line, wrapped here for USENET.)

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

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Title</title>
<link rel="stylesheet " media="screen" href="style.css " title="main"/>
<script type="text/javascript">
<!--
//<![CDATA[
function getLayer(SRC,ev ent){
var IE = document.all?tr ue:false;
var tempX = 0;
var tempY = 0;

var tDIV = document.getEle mentById(SRC);
tDIV.style.curs or = "hand";
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.s crollLeft;
tempY = event.clientY + document.body.s crollTop;
}
else { // grab the x-y pos.s if browser is NS
tempX = event.pageX;
tempY = event.pageY;
}
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}
tDIV.style.top = (tempY - 20);
tDIV.style.left = (tempX - 20);
tDIV.style.visi bility = "visible";
}

function hideLayer(SRC){
var tDIV = document.getEle mentById(SRC);
tDIV.style.visi bility='hidden' ;
}
//]]>
-->
</script>
</head>

--
[ Sugapablo ]
[ http://www.sugapablo.net <--personal | http://www.sugapablo.com <--music ]
[ http://www.2ra.org <--political | http://www.subuse.net <--discuss ]

Jul 23 '05 #1
1 2663


Sugapablo wrote:

var tDIV = document.getEle mentById(SRC); tDIV.style.top = (tempY - 20);
tDIV.style.left = (tempX - 20);


left/top with CSS need a number plus a unit so make that

tDIV.style.top = (tempY - 20) + 'px';
tDIV.style.left = (tempX - 20) + 'px';

The DOCTYPE puts Mozilla in strict mode and then it is picky about
correct CSS values (whether in script or in a stylesheet does not matter).

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3713
by: mike | last post by:
regards: I use Jtidy (api) to translate a HTML file into a "XHTML file". But The "XHTML file" cannot be identified by nokia 6600. Do I miss something important? Or this is Jtidy's weakness or bug? Can someone excellent to tell me the reason. best wishes
59
4746
by: Philipp Lenssen | last post by:
I've tested some of the new Nokia 6600 functionality. It ships with WAP2 and XHTML Support (it says). What it does is check the Doctype -- if it's not the XHTML Mobile Profile Doctype, but a XHTML1.0 Strict one, the media-handheld CSS is _ignored_. Only with the Nokia Doctype, the CSS is used. I find this really annoying as it goes against the whole idea of media-independent XHTML Strict along with stylesheets. On the good side, WML...
7
2027
by: Paul Marsh | last post by:
Hello everyone, I am attempting to create a xhtml page that uses a bit of dhtml. The javascript I am using uses document.getElementById('someId').style.someProperty; and is and external script. My page uses this dtd: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
1
32820
by: Sugapablo | last post by:
I have the following script (below). If I have the DOCYPE at the top, tDIV.style.top and tDIV.style.left don't return a value. If I remove the DOCTYPE from the first line, it works fine and returns and manipulates the values perfectly. What could possibly be the relationship? Why would the inclusion of a DOCTYPE tag at the top of a page break Javascript code? Browser: Mozilla Firefox. (note: the DOCTYPE on my site is all on one...
7
2295
by: hawat.thufir | last post by:
Given an xhtml file, how can I "export" the data to plain-text? That is, I want: google www.google.com Whereas, if I copy and paste what the browser shows, I lose the URL and end up with: google
6
2282
by: reynard | last post by:
I have a page that uses this doctype <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> but when I change to this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> it breaks my javascript. Particularly I have a code that try to set element.style.left, when I use the second doctype, FF complains "Error in parsing value for property 'left'. Declaration dropped"
15
5394
by: Lennart | last post by:
Hi folks, I have created an animated image gallery in dhtml. It works fine in Internet Explorer. In Firefox, it only works if I ommit the DOCTYPE tag. The page is valid xhtml-strict but with a xhtml1-strict DOCTYPE, I get a dead script and dozens of error messages like "Error in parsing value in property 'width'. Declaration dropped." on Line 0. This page doesn't work in Firefox but is valid xhtml:...
5
3138
by: Cruelemort | last post by:
All, I ran into a CSS problem when using the XHTML 1.0 transitional document type, so i have made a simplified version to show you all here. Basically i have written a very simple HTML page that contains two div elements each of a different class, the two classes (called test1 and test2) just set the positioning and z-layering of the div so the text on each one should overlap -
14
3042
by: tader | last post by:
so i got script like that <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Drag and Drop</title> <style> #slater { display:block;
0
8217
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8603
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4067
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2590
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1467
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.