|
DHTML Updates the Page
To write the new content to the document from the applet without affecting the already existing content you can use the <div> </div> tags of HTML. These tags are different for IE and Netscape.
HTML tag for Internet Explorer and Netscape 6
// any HTML content that will be updated must be
// identified with an id
<div id="iexplorer" width=700px ></div>
HTML tag for Netscape 4.x versions
<DATA><layer id="netscapev" ></layer></DATA>
I could have updated the HTML directly from the applet by referring to the appropriate ID, but for clarity, I chose to put the logic for updating the HTML in JavaScript functions. The following JavaScript code stores the name of the browser in a variable called ie.
applnname=navigator.appName;
if(applnname=="Microsoft Internet Explorer") {
ie=true;
}
else {
ie=false();
}
The applet builds the HTML with the new data, assigns it to the JavaScript variable 'content' and then invokes the assignData() method. The content value can be anything from plain HTML to XML to binary data.
//based on the browser I invoke the appropriate method
function assignData() {
if(ie) {explore();}
else {navig(); }
}
If the browser is IE or Netscape 6, the applet invokes the explore() method:
//content is a javascript variable. It represents the new data as HTML
function explore() {
iexplorer.innerHTML=content;
}
If the browser is Netscape version 4.0 and above, the applet invokes the navig() method:
function navig() {
document.netscapev.document.write('<DATA>' +
content + '</DATA>');
document.netscapev.document.close();
}
|
 |
TALK
BACK |
|
Are you using push techniques for your site? Is the method you're using similar to the one shown in this article? Let us know at web.dhtml.scripting.
|
|
|
|
|
|
|