如何让表行中的 Applet 动态调整大小

发布于 2024-08-07 14:17:55 字数 1490 浏览 6 评论 0原文

我需要将一个小程序插入表行并获取该表行的高度以根据浏览器的窗口大小动态调整大小。如果我为宽度和宽度设置固定值td-tag 中的高度,它可以很好地显示小程序,但我需要能够根据客户端的大小功能调整其大小,因此使用固定大小不是答案。

下面的代码片段应该说明我的问题所在:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JavaAppletTest </title>
    </head>

    <body bgcolor="#6f6f6f" >
        <table border="0" cellspacing="0" cellpadding="0" width="100%" >
            <tr valign="top">
                <td><img src="images/myheader.jpg" alt="myheader.jpg"></td>
                <td><img src="images/mylogo.jpg" alt="mylogo.jpg"></td>
            </tr>
            <tr >
                <td colspan="2" >
                    <object codetype="application/java"
                             classid="java:applets.MyTestApplet.class">
                        <param name="codebase" value="." >
                        <param name="archive" value="MyTestApplet.jar" >
                        <param name="code" value="applets.MyTestApplet" >
                    </object>
                </td>
            </tr>
        </table>
    </body>
</html>

我需要做什么才能使行维度动态化?

[编辑] jitter的答案表明了一个可能的解决方案。当用户调整窗口大小时,我还需要调整相关大小:什么事件和事件?我该怎么做?

I need to insert an applet into a table-row and get that table-row's height to dynamically resize according to the browser's window size. If I put fixed values for width & height in the td-tag, it shows the applet fine, but I need to be able to resize this according to the client's size capabilities, so using fixed sizes is not the answer.

The snippet below should illustrate where my problem lies:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JavaAppletTest </title>
    </head>

    <body bgcolor="#6f6f6f" >
        <table border="0" cellspacing="0" cellpadding="0" width="100%" >
            <tr valign="top">
                <td><img src="images/myheader.jpg" alt="myheader.jpg"></td>
                <td><img src="images/mylogo.jpg" alt="mylogo.jpg"></td>
            </tr>
            <tr >
                <td colspan="2" >
                    <object codetype="application/java"
                             classid="java:applets.MyTestApplet.class">
                        <param name="codebase" value="." >
                        <param name="archive" value="MyTestApplet.jar" >
                        <param name="code" value="applets.MyTestApplet" >
                    </object>
                </td>
            </tr>
        </table>
    </body>
</html>

What do I need to do to make the row-dimensions dynamic?

[edit]
jitter's answer indicates a possible solution. I also need to adjust the relevant sizes when the user resizes the window: what event & how do I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

誰認得朕 2024-08-14 14:17:55

我建议使用javascript编写object/embed标签并动态计算大小。

这基本上应该可以解决问题,但要注意获得正确的宽度和尺寸可能很棘手。我建议您参考查找浏览器窗口的大小

...
<head>
...
  <script type="text/javascript">
    window.onresize = function(event) {
      document.getElementById('myobject_tag').height = window.innerHeight;
      document.getElementById('myobject_tag').width = window.innerWidth;
    }
  </script>
</head>
...
<body bgcolor="#6f6f6f">
  <table border="0" cellspacing="0" cellpadding="0" width="100%">
    <tr valign="top">
      <td><img src="images/myheader.jpg" alt="myheader.jpg"></td>
      <td><img src="images/mylogo.jpg" alt="mylogo.jpg"></td>
    </tr>
    <script type="text/javascript">
      var height = window.innerHeight;
      var width = window.innerWidth;
      document.write(
        '<tr><td colspan="2"><object id="myobject_tag"\n' +
        'codetype="application/java"\n' +
        'classid="java:applets.MyTestApplet.class"\n' +
        'width="' + width + '"\n' +
        'height="' + height + '"\n>' +
        '<param name="codebase" value=".">\n' +
        '<param name="archive" value="MyTestApplet.jar">\n' +
        '<param name="code" value="applets.MyTestApplet">\n' +
        '</object></td></tr>'
      );
    </script>
  </table>
...

I suggest using javascript to write the object/embed tag and calculating the size dynamically.

This should do the trick basically but be aware of the fact that getting the correct width and size can be tricky. I refer you to Finding the size of the browser window.

...
<head>
...
  <script type="text/javascript">
    window.onresize = function(event) {
      document.getElementById('myobject_tag').height = window.innerHeight;
      document.getElementById('myobject_tag').width = window.innerWidth;
    }
  </script>
</head>
...
<body bgcolor="#6f6f6f">
  <table border="0" cellspacing="0" cellpadding="0" width="100%">
    <tr valign="top">
      <td><img src="images/myheader.jpg" alt="myheader.jpg"></td>
      <td><img src="images/mylogo.jpg" alt="mylogo.jpg"></td>
    </tr>
    <script type="text/javascript">
      var height = window.innerHeight;
      var width = window.innerWidth;
      document.write(
        '<tr><td colspan="2"><object id="myobject_tag"\n' +
        'codetype="application/java"\n' +
        'classid="java:applets.MyTestApplet.class"\n' +
        'width="' + width + '"\n' +
        'height="' + height + '"\n>' +
        '<param name="codebase" value=".">\n' +
        '<param name="archive" value="MyTestApplet.jar">\n' +
        '<param name="code" value="applets.MyTestApplet">\n' +
        '</object></td></tr>'
      );
    </script>
  </table>
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文