/    Sign up×
Community /Pin to ProfileBookmark

Script only works in quirks mode.

Hi, whenever I declare a doctype this DOM drag script stops working in FF and acts weirdly in IE.

[code]var ie = document.all;
var nn6 = document.getElementById &&! document.all;

var isdrag = false;
var x, y;
var dobj;

function movemouse( e ) {
if( isdrag ) {
dobj.style.left = nn6 ? tx + e.clientX – x : tx + event.clientX – x;
dobj.style.top = nn6 ? ty + e.clientY – y : ty + event.clientY – y;
return false;
}
}

function selectmouse( e ) {
var fobj = nn6 ? e.target : event.srcElement;
var topelement = nn6 ? “HTML” : “BODY”;

while (fobj.tagName != topelement && fobj.className != “dragme”) {
fobj = nn6 ? fobj.parentNode : fobj.parentElement;
}

if (fobj.className==”dragme”) {
if(isdrag==true)
{
isdrag = false;
}else{
isdrag = true;
dobj = document.getElementById(VV);
tx = parseInt(dobj.style.left+0);
ty = parseInt(dobj.style.top+0);
x = nn6 ? e.clientX : event.clientX;
y = nn6 ? e.clientY : event.clientY;
document.onmousemove=movemouse;
return false;
}
}
}

[/code]

-Thankyou, GB.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@tianxzJul 07.2009 — clientX is not compatible to all browser.

to clientx, we should set:

px = e.pageX || (e.clientX + (document.documentElement.scrollLeft ||document.body.scrollLeft)-(document.documentElement.clientLeft || 0)).

for detail:

http://mrlu.host22.com/read.php?tid=45
Copy linkTweet thisAlerts:
@GB_001authorJul 08.2009 — I don't thinks that's the problem because it works on all browsers in quirks mode but screws up when I try any doctype.
×

Success!

Help @GB_001 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ,
analytics: Fullres
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Marika,
tipped: article
amount: 1000 SATS,

tipper: @hatem774,
tipped: article
amount: 1 SATS,

tipper: @nearjob,
tipped: article
amount: 1000 SATS,
)...