Hello,
I am a newb of Java applets. In the recent day, i got with a java code and is working properly with my current web page.
I'm herewith attaching that source code. You just cut and paste it, save it as name.htm, and run it. Interesting pop up. am i right?

But i don't know how it is working. i had a look at the java section. but can't! Anybody can help, to describe the java (<script>....</script>) section of the said script??
Anish V
(New Delhi, India)

Attachments
<html>
<head>
<title>This is my practice section</title>

<script type="text/javascript">
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

function drag_drop(e)
	{
	if (ie4&&dragapproved)
		{
		crossobj.style.left=tempx+event.clientX-offsetx
		crossobj.style.top=tempy+event.clientY-offsety
		return false
		}

	else if (ns6&&dragapproved)
		{
		crossobj.style.left=tempx+e.clientX-offsetx+"px"
		crossobj.style.top=tempy+e.clientY-offsety+"px"
		return false
		}
	}

function initializedrag(e)
	{
	crossobj=ns6? document.getElementById("showimage") : document.all.showimage
	var firedobj=ns6? e.target : event.srcElement
	var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"


	if (firedobj.id=="dragbar")
		{
		offsetx=ie4? event.clientX : e.clientX
		offsety=ie4? event.clientY : e.clientY
		tempx=parseInt(crossobj.style.left)
		tempy=parseInt(crossobj.style.top)
		dragapproved=true
		document.onmousemove=drag_drop
		}
	}
document.onmouseup=new Function("dragapproved=false")


function hidebox()
	{
	crossobj=ns6? document.getElementById("showimage") : document.all.showimage
	if (ie4||ns6)
	crossobj.style.visibility="hidden"
	else if (ns4)
	document.showimage.visibility="hide"
	}

</script>
</head>



<body>
<div id="showimage" style="position:absolute;width:125px;left:125px;top:125px">
<table border="0" width="500" bgcolor="lightgreen" cellspacing="0" cellpadding="2">
  <tr>
    <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"
    height="36px">
      <tr>
        <td id="dragbar" style="cursor:hand; cursor:pointer" width="100%" onMousedown="initializedrag(event)"><ilayer width="100%" onSelectStart="return false"><layer width="100%" onMouseover="dragswitch=1;if (ns4) drag_dropns(showimage)" onMouseout="dragswitch=0">
<font face="Verdana" color="#FFFFFF"><strong><small>Announcement Box</small></strong></font></layer></ilayer></td>
        <td style="cursor:hand"><a href="#" onClick="hidebox();return false"><img src="close.gif" width="16px"
        height="14px" border=0></a></td>
      </tr>
      <tr>
        <td width="100%" bgcolor="pink" style="padding:4px" colspan="2">

<!-- PUT YOUR CONTENT BETWEEN HERE -->

Hai, This is Anish from New Delhi
I am doing MBA(IT)
degree holder<br>
asdfkjhsdk<br>
sdhsdf

<!-- END YOUR CONTENT HERE -->

</td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</div>


</body>
</html>

The text file which you attached is no a java stuff, it is a HTML with additional JavaScript functionality.
What are differences:

  • Java is an object-oriented programming language developed by Sun Microsystems in the early 1990s. Java applications are compiled to bytecode, which at runtime is either interpreted or compiled to native machine code for execution. (material from wikipedia.org)
  • JavaScript is the name of Netscape Communications Corporation's and now the Mozilla Foundation's implementation of the ECMAScript standard, a scripting language based on the concept of prototype-based programming. The language is best known for its use in websites (as client-side JavaScript), but is also used to enable scripting access to objects embedded in other applications. (material from wikipedia.org)

To learn about JAVA Apllets check this http://java.sun.com/docs/books/tutorial/deployment/applet/index.html

Thanks Peter! I got the website that you has introduced. But you didn't mind what I have asked. I seek help from the script that i had attached:

var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all
function drag_drop(e)
{
if (ie4&&dragapproved)
{
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved)
{
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}
-----------------------------------------------------
THIS ONE!! From where can i find the tips about 'var', 'document.all','getelementbyid'? Did you notice that? If u can give me the link of the study materials so that i can reach there......

Anish V
(New Delhi, India)

And, of course, as mentioned in peter_budo's first post, that is JavaScript, not Java. Java != JavaScript. Find a JavaScript forum somewhere, rather than a Java Forum.

And, of course, as mentioned in peter_budo's first post, that is JavaScript, not Java. Java != JavaScript. Find a JavaScript forum somewhere, rather than a Java Forum.

masijad,
Can you clarify what you have mentioned?

JavaScript and Java are two different programming languages. The name is similar, but they were developed by two different companies. JavaScript purposely took on that name to "ride the Java wave", but it has only syntactical similarities. It is not the same language. Google search for a forum dedicated to JavaScript and post your question there.

This article has been dead for over six months. Start a new discussion instead.