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:relative;
border:0px;
}
#main_box {
position:relative;
width:113px;
height:22px;
background:url(background_slate.jpg) no-repeat;
border:0px;
}
</style>
<script>
if (navigator.appName == "Microsoft Internet Explorer") { var Browser = "IE"; } else { var Browser = "FF"; }
var MoveIT = "";
function startDrag() {
OffsetX = MouseX - (document.getElementById('slater').style.left).rep lace("px","");
MoveIT = "yes";
}
function mouseMoveFF(event) {
MouseX = event.clientX;
if (MoveIT == "yes") {
document.getElementById('slater').style.left = MouseX - OffsetX;
if(document.getElementById('slater').style.left.re place("px","") <= 0) {
document.getElementById('slater').style.left = 0+"px";
} else if ((document.getElementById('slater').style.left.rep lace("px","")) >= 100) {
document.getElementById('slater').style.left = 100+"px";
}
var speed = document.getElementById('slater').style.left.repla ce("px","") / 10;
var fix_pt = (document.getElementById('slater').style.left != "0pt") ? speed : '0';
document.getElementById('speed').innerHTML = fix_pt;
}
}
function mouseMoveIE() {
MouseX = event.clientX;
if (MoveIT == "yes") {
document.getElementById('slater').style.left = MouseX - OffsetX;
if(document.getElementById('slater').style.left.re place("px","") <= 0) {
document.getElementById('slater').style.left = 0+"px";
} else if ((document.getElementById('slater').style.left.rep lace("px","")) >= 100) {
document.getElementById('slater').style.left = 100+"px";
}
var speed = document.getElementById('slater').style.left.repla ce("px","") / 10;
document.getElementById('speed').innerHTML = speed;
}
}
if (Browser == "IE") { document.onmousemove = mouseMoveIE; } else { document.onmousemove = mouseMoveFF; }
document.onmouseup = function () { MoveIT = ""; }
</script>
</head>
<body>
<div id="main_box">
<div id="slater" onMouseDown="startDrag()"></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.dtd"> 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)
14 3019
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.
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.dtd">
<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="javascript" src="script.js"></script>
<link type="text/css" rel="stylesheet" href="css.css" />
</head>
<body>
<div id="main_box">
<div id="slater" onMouseDown="startDrag()"></div>
</div>
<div id="speed">0</div>
</body>
</html>
[/HTML]
have any ideas hat to do now??
but on ie it works
onload is not working or ma bey im not using it right can you tell me how to use it???
Can you show what code you've tried?
PS. changed the thread title to better describe the problem.
HTML Code:
[HTML]
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1257" />
<title>Drag</title>
<script type="text/javascript" language="javascript" src="script.js"></script>
<link type="text/css" rel="stylesheet" href="css.css" />
</head>
<body>
<div id="main_box">
<div id="slater" onMouseDown="startDrag()"></div>
</div>
<div id="speed">0</div>
</body>
</html>
[/HTML]
Javascript code: -
if (navigator.appName == "Microsoft Internet Explorer") { var Browser = "IE"; } else { var Browser = "FF"; }
-
var MoveIT = "";
-
-
function startDrag() {
-
OffsetX = MouseX - (document.getElementById('slater').style.left).replace("px","");
-
MoveIT = "yes";
-
}
-
-
function mouseMoveFF(event) {
-
MouseX = event.clientX;
-
if (MoveIT == "yes") {
-
document.getElementById('slater').style.left = MouseX - OffsetX;
-
-
if(document.getElementById('slater').style.left.replace("px","") <= 0) {
-
document.getElementById('slater').style.left = 0+"px";
-
} else if ((document.getElementById('slater').style.left.replace("px","")) >= 100) {
-
document.getElementById('slater').style.left = 100+"px";
-
}
-
-
var speed = document.getElementById('slater').style.left.replace("px","") / 10;
-
var fix_pt = (document.getElementById('slater').style.left != "0pt") ? speed : '0';
-
document.getElementById('speed').innerHTML = fix_pt;
-
}
-
}
-
-
function mouseMoveIE() {
-
MouseX = event.clientX;
-
if (MoveIT == "yes") {
-
document.getElementById('slater').style.left = MouseX - OffsetX;
-
-
if(document.getElementById('slater').style.left.replace("px","") <= 0) {
-
document.getElementById('slater').style.left = 0+"px";
-
} else if ((document.getElementById('slater').style.left.replace("px","")) >= 100) {
-
document.getElementById('slater').style.left = 100+"px";
-
}
-
-
var speed = document.getElementById('slater').style.left.replace("px","") / 10;
-
document.getElementById('speed').innerHTML = speed;
-
}
-
}
-
-
if (Browser == "IE") { document.onmousemove = mouseMoveIE; } else { document.onmousemove = mouseMoveFF; }
-
document.onmouseup = function () { MoveIT = ""; }
-
So like i sad before on ie it works but not on ff. I just cant find the bug
Move the onmousedown in the slater div into an onload.
sorry did not understand can you show me an example?
sorry did not understand can you show me an example?
For example: - window.onload=function() {
-
document.getElementById("slater").onmousedown=startDrag;
-
}
You could use addEventListener/attachEvent instead.
-
window.onload = function() {
-
if (Browser == "IE") {
-
document.getElementById("slater").onmousemove = mouseMoveIE;
-
} else {
-
document.getElementById("slater").onmousemove = mouseMoveFF;
-
}
-
}
i did it like this bus it still is not working
In your HTML code you have:
[HTML]<div id="slater" onMouseDown="startDrag()"></div>[/HTML] Have you removed the onMouseDown?
i dind remove this onmousedown=startdarg();
heres my javascript
still it's nowworking on ff but working on ie -
if (navigator.appName == "Microsoft Internet Explorer") { var Browser = "IE"; } else { var Browser = "FF"; }
-
var MoveIT = "";
-
-
function startDrag() {
-
OffsetX = MouseX - (document.getElementById('slater').style.left).replace("px","");
-
MoveIT = "yes";
-
}
-
-
function mouseMoveFF(event) {
-
MouseX = event.clientX;
-
if (MoveIT == "yes") {
-
document.getElementById('slater').style.left = MouseX - OffsetX;
-
-
if(document.getElementById('slater').style.left.replace("px","") <= 0) {
-
document.getElementById('slater').style.left = 0+"px";
-
} else if ((document.getElementById('slater').style.left.replace("px","")) >= 100) {
-
document.getElementById('slater').style.left = 100+"px";
-
}
-
-
var speed = document.getElementById('slater').style.left.replace("px","") / 10;
-
var fix_pt = (document.getElementById('slater').style.left != "0pt") ? speed : '0';
-
document.getElementById('speed').innerHTML = fix_pt;
-
}
-
}
-
-
function mouseMoveIE() {
-
MouseX = event.clientX;
-
if (MoveIT == "yes") {
-
document.getElementById('slater').style.left = MouseX - OffsetX;
-
-
if(document.getElementById('slater').style.left.replace("px","") <= 0) {
-
document.getElementById('slater').style.left = 0+"px";
-
} else if ((document.getElementById('slater').style.left.replace("px","")) >= 100) {
-
document.getElementById('slater').style.left = 100+"px";
-
}
-
-
var speed = document.getElementById('slater').style.left.replace("px","") / 10;
-
document.getElementById('speed').innerHTML = speed;
-
}
-
}
-
-
window.onload = function() {
-
if (Browser == "IE") {
-
document.getElementById("slater").onmousemove = mouseMoveIE;
-
} else {
-
document.getElementById("slater").onmousemove = mouseMoveFF;
-
}
-
}
-
-
-
document.onmouseup = function () { MoveIT = ""; }
-
i dind remove this onmousedown=startdarg();
heres my javascript
still it's nowworking on ff but working on ie
You'll need to add the onmousedown to the onload too.
if i do it like this -
window.onload = function() {
-
document.getElementById("slater").onmousedown = startdarg;
-
if (Browser == "IE") {
-
document.getElementById("slater").onmousemove = mouseMoveIE;
-
} else {
-
document.getElementById("slater").onmousemove = mouseMoveFF;
-
}
-
}
-
it will not work nor even on ie
The onmousemove should probably be on the document: - document.onmousemove = ...
as you originally had it.
It's startDrag (JavaScript is case-sensitive).
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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>
|
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...
|
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...
|
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></...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| | |