Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem when moving the layer in NS! Help me, please!!!

Status
Not open for further replies.

tuyle

Programmer
Mar 19, 2001
4
VN
Hi,

I have written the DHTML file. It contents 1 layer (DIV) to handle mouse events:
1/ Click on the caption to move the layer.
2/ Click on the buttons to process specified works.

It works well with IE4 but has some problems with NS: the buttons are disappeared when moving. Please copy the code below and run on NS for more details.

<!--Code-->

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script language=&quot;JavaScript&quot;>

document.writeln (&quot;<STYLE TYPE=\&quot;text/css\&quot;>&quot;);
document.writeln (&quot;DIV {font-size:1pt}&quot;);
document.writeln (&quot;.Text {font-weight:Bold; font-size:10pt}&quot;);
document.writeln (&quot;.popper{position : absolute;visibility : hidden;z-index:110;}&quot;);
document.writeln(&quot;</STYLE>&quot;);

var skn = null;
</script>
</head>

<body bgcolor=&quot;#FFFFFF&quot;>
<DIV ID=&quot;topdeck&quot; CLASS=&quot;popper&quot; style=&quot;WIDTH:1px; HEIGHT:1px;&quot; onMouseDown=&quot;mouseDown(event)&quot;>&nbsp;</DIV>

<script language=&quot;JavaScript&quot;>

mStatus = 0;
oldX = 1;
oldY = 1;
newX = 1;
newY = 1;
sknX = 200;
sknY = 250;
var isIE = document.all? true: false;


function frameOnLoad(skn, doc){
EndDialog(skn, doc);
}


function mouseDown(e){
if(isIE){
var frame=window;
if(typeof frame!='object')return;
if (event.y - parseInt(skn.top) > 25) return;

oldX = frame.event.clientX + frame.document.body.scrollLeft;
oldY = frame.event.clientY + frame.document.body.scrollTop;
}else {
if (e.pageY - parseInt(skn.top) > 25) return;

oldX = e.pageX;
oldY = e.pageY;
}
mStatus = 1;
}

function mouseUp(e){
if (mStatus == 1){
EndDialog(skn, document);
}
}

function mouseMove(e){
var frame = window;
if(typeof frame != 'object')return;
var x = (!isIE) ? e.pageX : frame.event.clientX + frame.document.body.scrollLeft;
var y = (!isIE) ? e.pageY : frame.event.clientY + frame.document.body.scrollTop;

if( mStatus == 1){
skn.left = parseInt(skn.left) + x - oldX;
skn.top = parseInt(skn.top) + y - oldY;
sknX = parseInt(skn.left);
sknY = parseInt(skn.top);
oldX = x;
oldY = y;
}
newX = x;
newY = y;

}

function End(){
//parent.setEnableApplet(true);
alert(&quot;End!&quot;);
}

function Restart(){
//parent.setEnableApplet(true);
alert(&quot;Restart!&quot;);
}

function EndDialog(skn, doc) {

var strMsg = &quot;You are at the en of the lesson. <br>Please choose the next action&quot;;

var strEndLesson = '<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&quot;>\n'
+ '<table border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>\n'
+ '<tr> <td>\n'
+ '<table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; bgcolor=&quot;#CCCCCC&quot; width=&quot;295&quot;>\n'
+ '<tr> <td colspan=&quot;2&quot; height=&quot;25&quot; bgcolor=&quot;#3333FF&quot;><font color=&quot;#FFFFFF&quot;>Test</font></td> </tr>\n'
+ '<tr> <td colspan=&quot;2&quot; height=&quot;60&quot; style=&quot;cursor:normal&quot;> <p align=&quot;center&quot;>' + strMsg + '</p> </td> </tr>\n'
+ '<tr>\n'
+ '<td width=&quot;143&quot; height=&quot;45&quot; align=&quot;center&quot;> <input type=&quot;button&quot; name=&quot;RestartLesson&quot; value=&quot;Restart Lesson&quot; onclick=&quot;Restart()&quot;> </td>\n'
+ '<td width=&quot;152&quot; height=&quot;45&quot; align=&quot;center&quot;> <input type=&quot;button&quot; name=&quot;EndLesson&quot; value=&quot; End Lesson &quot; onclick=&quot;End()&quot;> </td>\n'
+ '</tr>\n'
+ '</table>\n'
+ '</td> </tr>\n'
+ '</table>\n'
+ '</form>';



skn.left = sknX;
skn.top = sknY;
mStatus =0;
//alert(&quot;skn.left = &quot; + skn.left + &quot;skn.top = &quot; + skn.top);

if (!isIE) {
//parent.setEnableApplet(false);
window.onfocus = false;

skn.document.write(strEndLesson);
skn.document.close();
skn.visibility = &quot;visible&quot;;
}else {
//parent.setEnableApplet(false);
doc.all(&quot;topdeck&quot;).innerHTML = strEndLesson;
skn.visibility = &quot;visible&quot;;
}

}

skn = (document.layers) ? document.topdeck : topdeck.style;
if (document.layers){
document.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
skn.document.captureEvents(Event.MOUSEDOWN);
skn.document.onmousedown=mouseDown;
}
else{
document.onselectstart=new Function(&quot;return false;&quot;);
}
document.onmouseup=mouseUp;
document.onmousemove = mouseMove;

setTimeout(&quot;EndDialog(skn, document)&quot;,1500);
</script>
</body>
</html>

Thanks for your support! Pls contact me via mail: tuyle@psv.com.vn
 
&quot; Please copy the code below and run on NS for more details.&quot; --> yes ! fine ! please work for me as well !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top