473,771 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code works with HTML 4.0 Transitional DOCTYPE, but not with XHTML 1.0 Transitional

43 New Member
so i got script like that

[HTML]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Drag and Drop</title>
<style>
#slater {
display:block;
width:13px;
height:22px;
background:url( slater.gif);
cursor:pointer;
position:relati ve;
border:0px;
}
#main_box {
position:relati ve;
width:113px;
height:22px;
background:url( background_slat e.jpg) no-repeat;
border:0px;
}
</style>
<script>

if (navigator.appN ame == "Microsoft Internet Explorer") { var Browser = "IE"; } else { var Browser = "FF"; }
var MoveIT = "";

function startDrag() {
OffsetX = MouseX - (document.getEl ementById('slat er').style.left ).replace("px", "");
MoveIT = "yes";
}

function mouseMoveFF(eve nt) {
MouseX = event.clientX;
if (MoveIT == "yes") {
document.getEle mentById('slate r').style.left = MouseX - OffsetX;

if(document.get ElementById('sl ater').style.le ft.replace("px" ,"") <= 0) {
document.getEle mentById('slate r').style.left = 0+"px";
} else if ((document.getE lementById('sla ter').style.lef t.replace("px", "")) >= 100) {
document.getEle mentById('slate r').style.left = 100+"px";
}

var speed = document.getEle mentById('slate r').style.left. replace("px","" ) / 10;
var fix_pt = (document.getEl ementById('slat er').style.left != "0pt") ? speed : '0';
document.getEle mentById('speed ').innerHTML = fix_pt;
}
}

function mouseMoveIE() {
MouseX = event.clientX;
if (MoveIT == "yes") {
document.getEle mentById('slate r').style.left = MouseX - OffsetX;

if(document.get ElementById('sl ater').style.le ft.replace("px" ,"") <= 0) {
document.getEle mentById('slate r').style.left = 0+"px";
} else if ((document.getE lementById('sla ter').style.lef t.replace("px", "")) >= 100) {
document.getEle mentById('slate r').style.left = 100+"px";
}

var speed = document.getEle mentById('slate r').style.left. replace("px","" ) / 10;
document.getEle mentById('speed ').innerHTML = speed;
}
}

if (Browser == "IE") { document.onmous emove = mouseMoveIE; } else { document.onmous emove = mouseMoveFF; }
document.onmous eup = function () { MoveIT = ""; }

</script>
</head>
<body>

<div id="main_box">
<div id="slater" onMouseDown="st artDrag()"></div>
</div>
<div id="speed" style="font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#666666;" >0</div>
</body>
</html>
[/HTML]
so it works file but this is my problem it's made on <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> HTML 4.0 Transitional i need it to be <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d"> but this i my problem when i change HTML 4.0 Transitional to XHTML 1.0 Transitional it stops working so can some one tell me how to make my script work with XHTML 1.0 Transitional (on ie XHTML 1.0 Transitional works but not on FF)
Oct 17 '07 #1
14 3050
mrhoo
428 Contributor
Take the script out of the html and link to it with
<script type="text/javascript" src=></script> in the head, and include a title element in the head.
put the event assignment in an onload call in the remote script.
Oct 17 '07 #2
tader
43 New Member
i did like this and it still not working
[HTML]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1257" />
<title>Drag</title>
<script type="text/javascript" language="javas cript" src="script.js" ></script>
<link type="text/css" rel="stylesheet " href="css.css" />

</head>
<body>
<div id="main_box">
<div id="slater" onMouseDown="st artDrag()"></div>
</div>
<div id="speed">0</div>
</body>
</html>
[/HTML]

have any ideas hat to do now??
but on ie it works
Oct 17 '07 #3
tader
43 New Member
onload is not working or ma bey im not using it right can you tell me how to use it???
Oct 19 '07 #4
acoder
16,027 Recognized Expert Moderator MVP
Can you show what code you've tried?

PS. changed the thread title to better describe the problem.
Oct 19 '07 #5
tader
43 New Member
HTML Code:
[HTML]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1257" />
<title>Drag</title>
<script type="text/javascript" language="javas cript" src="script.js" ></script>
<link type="text/css" rel="stylesheet " href="css.css" />

</head>
<body>
<div id="main_box">
<div id="slater" onMouseDown="st artDrag()"></div>
</div>
<div id="speed">0</div>
</body>
</html>
[/HTML]

Javascript code:
Expand|Select|Wrap|Line Numbers
  1. if (navigator.appName == "Microsoft Internet Explorer") { var Browser = "IE"; } else { var Browser = "FF"; }
  2. var MoveIT = "";
  3.  
  4. function startDrag() {
  5.     OffsetX = MouseX - (document.getElementById('slater').style.left).replace("px","");
  6.     MoveIT = "yes";
  7. }
  8.  
  9. function mouseMoveFF(event) {
  10.     MouseX = event.clientX;
  11.     if (MoveIT == "yes") {
  12.         document.getElementById('slater').style.left = MouseX - OffsetX;
  13.  
  14.         if(document.getElementById('slater').style.left.replace("px","") <= 0) {
  15.             document.getElementById('slater').style.left = 0+"px";
  16.         } else if ((document.getElementById('slater').style.left.replace("px","")) >= 100) {
  17.             document.getElementById('slater').style.left = 100+"px";
  18.         }
  19.  
  20.         var speed = document.getElementById('slater').style.left.replace("px","") / 10;
  21.         var fix_pt = (document.getElementById('slater').style.left != "0pt") ? speed : '0';
  22.         document.getElementById('speed').innerHTML = fix_pt;
  23.     }
  24. }
  25.  
  26. function mouseMoveIE() {
  27.     MouseX = event.clientX;
  28.     if (MoveIT == "yes") {
  29.         document.getElementById('slater').style.left = MouseX - OffsetX;
  30.  
  31.         if(document.getElementById('slater').style.left.replace("px","") <= 0) {
  32.             document.getElementById('slater').style.left = 0+"px";
  33.         } else if ((document.getElementById('slater').style.left.replace("px","")) >= 100) {
  34.             document.getElementById('slater').style.left = 100+"px";
  35.         }
  36.  
  37.         var speed = document.getElementById('slater').style.left.replace("px","") / 10;
  38.         document.getElementById('speed').innerHTML = speed;
  39.     }
  40. }
  41.  
  42. if (Browser == "IE") {  document.onmousemove = mouseMoveIE; } else { document.onmousemove = mouseMoveFF; }
  43. document.onmouseup = function () { MoveIT = ""; }
  44.  
So like i sad before on ie it works but not on ff. I just cant find the bug
Oct 20 '07 #6
acoder
16,027 Recognized Expert Moderator MVP
Move the onmousedown in the slater div into an onload.
Oct 20 '07 #7
tader
43 New Member
sorry did not understand can you show me an example?
Oct 20 '07 #8
acoder
16,027 Recognized Expert Moderator MVP
sorry did not understand can you show me an example?
For example:
Expand|Select|Wrap|Line Numbers
  1. window.onload=function() {
  2. document.getElementById("slater").onmousedown=startDrag;
  3. }
You could use addEventListene r/attachEvent instead.
Oct 20 '07 #9
tader
43 New Member
Expand|Select|Wrap|Line Numbers
  1. window.onload = function() {
  2.     if (Browser == "IE") {  
  3.         document.getElementById("slater").onmousemove = mouseMoveIE; 
  4.     } else { 
  5.         document.getElementById("slater").onmousemove = mouseMoveFF; 
  6.     }
  7. }
i did it like this bus it still is not working
Oct 21 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

14
2620
by: Akbar | last post by:
Hey there, Big-time curiosity issue here... Here's the test code (it's not that long)... it's to display a large number of image links with captions, ideally pulled in from an external file (that part's not here -- spotlighting the problem code): --------BEGIN CODE PAGE------------ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
20
2584
by: Alan Silver | last post by:
Hello, I have read about the problems that IE has when using a doctype of HTML 4.01 Transitional. I was advised to use Strict wherever possible. My question is, does the same apply to XHTML 1.0 Transitional? I develop sites using ASP.NET, which emits valid XHTML 1.0 Transitional, but not XHTML 1.0 Strict (for example, it includes a hidden form field with the name of _VIEWSTATE, which isn't valid in Strict, but is in Transitional).
11
2786
by: Nathan Sokalski | last post by:
I add several JavaScript events (onchange, onkeypress, etc.) to Controls using the Add method of the Attributes collection. However, if the JavaScript code contains certain characters, such as & or < or several others, it converts them to html, such as &amp; or &lt; which can sometimes cause my scripts not to work. How can I prevent ASP.NET from doing this? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
4
1305
by: pamelafluente | last post by:
I am trying to pass a javascript variable to ASP. It almost works, except for the postback part. Infact if one clicks on the div and on the button it can be seen that the variable passes through. Can anyone help to do the postback? Here is my complete code: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
6
7866
by: Rolf Welskes | last post by:
Hello, if I have for example: <table style="width: 100%; height: 100%;" border="1"> <tr> <td style="width: 100px">k </td> <td style="width: 100px">k </td> </tr>
1
1233
by: rampabbaraju | last post by:
In my project I have two web pages with the same functionality, but the controls are placed in different places in each page. Application compiles and runs properly and produces the results I am expecting. But the designer shows errors. Is it OK to do that way or not? My two files are like this Default.aspx----- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
21
4609
by: =?iso-8859-2?Q?K=F8i=B9tof_=AEelechovski?= | last post by:
It is common knowledge that XHTML is better HTML and you can serve XHTML content as HTML. However, the second statement is incorrect, for various reasons; it is enough to say that the HTML validator does not tolerate XML-style empty tags. It seems serving XHTML to the browser is of no advantage and can cause serious problems if the browser does not understand the difference. This raises the question of downgrading XHTML to HTML. I could...
27
2839
by: pamela fluente | last post by:
Hello, for the following code, VS suggests that construct (width= height= ) is out of date and a newer one is recommended: <table><tr><td width="92" height="38" valign="middle">AnyThing</td></ tr></table> Would you please tell me the right construct (clearly must be functionally equivalent).
70
5403
mideastgirl
by: mideastgirl | last post by:
I have recently been working on a website for an honors association, and have a lot of difficulty but have found help from those on this site. I would like to see if I can get some more help on a different issue than what I was initially having. I am working on storing data collected from a form on my website. I would like the information to be stored into MySQL once entered by users. I have googled this question and have tried multiple...
0
9619
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
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
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...
0
9911
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6713
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.