web复习(四)

JavaScript编程

1.计算圆的面积。

(1)表单中设置2个文本框、1个按钮、1个重置按钮,其中圆的面积文本框设置为只读;

(2)编写两个自定义函数,分别是计算圆的面积函数area(radius)、在页面上显示结果show()

,并在show()函数中调用area(radius)函数;

(3)输入完半径后,点击"计算圆的面积"按钮后,将计算结果显示在"圆的面积"文本框中;

(4)点击"重置"按钮后,将所有文本框清空;

(5)圆的面保留2位小数。

html 复制代码
<html>
    <head>
        <title>计算圆面积</title>
        <script type="text/javascript">
            function area(radius) {
                var circlearea = Math.PI*radius*radius;
                return circlearea;
            }
            function show() {
                var radius = document.getElementById("radius_text").value;
                document.getElementById("area_text").value = area(radius).toFixed(2);
            }
        </script>
    </head>
    <body>
        <h3>计算圆的面积</h3>
        <form method="post">
            圆的半径:<input type="text" name="radius_text" id="radius_text"><br>
            圆的面积:<input type="text" name="area_text" id="area_text" readonly><br>
            <input type="button" value="计算圆的面积" onclick="show();">
            <input type="reset">
        </form>
    </body>
</html>

2.页面布局

按如下要求实现"厂字型"页面布局效果。

(1)页面标题为"厂字型页面布局";

(2)页面布局采用主体水平分割成上、 中、下三个部分,比例为10%、80%、10%;

(3)中间部分垂直分割成左、右两部分,比例分别为25%、75%;

(4)假设每个子窗口显示的网页分别为top.html、left.html、right.html、bottom.html,在index.html文件中给每一个子窗口中指定显示的网页。

html 复制代码
<html>
    <head>
        <title>厂字型页面布局</title>
    </head>
   <frameset rows="10%,80%,*" bordercolor="#3300ff">
    <frame src="" name="top">
        <frameset cols="25%,*">
            <frame src="" name="left">
            <frame src="" name="right">    
        </frameset>
        <frame src="" name="bottom">
   </frameset>
</html>
相关推荐
夜焱辰9 小时前
浏览器端 Agent 的文件版本管理:不用 Git,基于 OPFS + SQLite 自己造了一个
前端·人工智能
梦想的颜色9 小时前
TypeScript 完全指南(下):从类型体操到生产级配置
前端·javascript·typescript
Hi~晴天大圣11 小时前
npm使用介绍
前端·npm·node.js
888CC++12 小时前
如何在 C 语言中进行程序调试?
前端·javascript·算法
喵个咪12 小时前
基于 Taro 的 Headless CMS 多端前端架构:技术解析与二次开发导引
前端·react.js·taro
狂炫冰美式12 小时前
你还在古法PPT吗,试试HTML呢?免费编辑导出工具给 xdm 放这了
前端·后端·github
万少13 小时前
未来组织的分水岭不是员工数量,而是人才密度
前端·后端·面试
任磊abc13 小时前
nextjs16配置eslint+prettier
前端·eslint·nextjs·prettier
x***r15113 小时前
Another-Redis-Desktop-Manager.1.3.7安装步骤详解(附Redis可视化连接与Key管理教程)
前端·bootstrap·html
Captaincc13 小时前
你真的知道自己把 AI 用在了哪里吗?这是 Vibe Usage 想回答的问题
前端·vibecoding