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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Safari Applets

Status
Not open for further replies.

rlarson

Programmer
Nov 15, 2002
18
0
0
US
The following code works just fine in IE6, but in Safari it's ignored. Is there a way to resize an applet after it's loaded in Safari?

Thanks in advance.

Code:
<html>

<head>
  <title>Viewer</title>
</head>

<script language="JavaScript">
    function resizeGrid()
    { /* Make the applet fit the window */
      if(document.myApplet != null)
      { document.myApplet.width = document.body.clientWidth;
        document.myApplet.height = document.body.clientHeight;
      }  
    } 
    function init()
    { resizeGrid();
    }
</script> 

<body onResize="resizeGrid();" onload="init();">

<applet code="wviewer.ItemViewer" codebase="/customviewer/" name="myApplet" id="myApplet" width="625" height="325" mayscript>

</applet>
</body>
</html>
 
When you say "it doesn't work in Safari" do you get any errors (open up the javascript console by typing "javascript:" in the location bar)?

Jeff
 
No errors. Java console doesn't show anything except for loading the applet.
 
Does changing your code to use DOM methods make any difference? Try replacing your script with this and see what happens:

Code:
<script type="text/javascript">
<!--
	function resizeGrid() {
		var myAppletObj = document.getElementById('myApplet');
		if(myAppletObj != null) {
			myApplet.setAttribute('width', document.body.clientWidth);
			myApplet.setAttribute('height', document.body.clientHeight);
		}
	}

	function init() {
		resizeGrid();
	}
//-->
</script>

Also, try just writing a script which alerts "document.body.clientWidth" - it may turn out that Safari doesn't actually support that property at all - which would be one reason your script isn't working.

Hope this helps,
Dan

 
I've added this after setting the width and height:
window.status = "width = " + document.body.clientWidth + " height = " + document.body.clientHeight;

The status bar displays the changes as the window is resized, but the applet doesn't change.

Any other suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top