Enlightensoft's Blog

Helping in your each step

  • Categories

  • Authors

How to Reload Applet or Remove class file Caching for Applet

Posted by Pankil Patel on August 26, 2012

Step1: Add below script to your HTML page after End of Body (After </BODY> tag)

<script type=”text/javascript”>
window.APPLET_WRAPER_TAG = “object”;
//window.APPLET_WRAPER_TAG = “APPLET”;
//window.APPLET_WRAPER_TAG = “EMBED”;

window.TAG_TYPE = “application/x-java-applet”;

window.currectApplet = true;
window.allAppletsHTML = new Array();
window.allApplets = new Array();

reloadApplet();

function reloadApplet() {

var resultListObects = getallAppletsHTML();

if (window.currectApplet) {
for (i = 0; i < resultListObects.length; i++) {
window.allAppletsHTML[i] = resultListObects[i].outerHTML;
var htmls = resultListObects[i].outerHTML.split(‘.class’);
htmls[0] = htmls[0] + ‘.class?PankilPatel’;
var html = htmls[0] + htmls[1];
resultListObects[i].outerHTML = html;
}
window.currectApplet = false;
} else {
for (i = 0; i < resultListObects.length; i++) {
resultListObects[i].outerHTML = window.allAppletsHTML[i];
}
window.currectApplet = true;
}
if (!window.currectApplet) {
reloadApplet(resultListObects);
}
}

function getallAppletsHTML() {
var listObects = document
.getElementsByTagName(window.APPLET_WRAPER_TAG);
var resultListObects = new Array();
for (i = 0, index = 0; i < listObects.length; i++) {
if (window.APPLET_WRAPER_TAG.toUpperCase() == “APPLET”
|| listObects[i].type == window.TAG_TYPE) {
resultListObects[index] = listObects[i];
index++;
}
}
return resultListObects;
}
</script>

 

Step2: Configure value of TAG which is used to display Applet in HTML Page, like object, APPLET or EMBED into first line of script.

Step3: Same way change value of “window.TAG_TYPE” to type given in TAG which is used to display applet, into second line of script.

 

Now no need to restart your any browser after applet change.

Enjoy your hassle free development of Applet……………….. 🙂

 

Note: It will work only if you have used only one way to import applet into your HTML file which is any one of  object, APPLET or EMBED.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: