1. 编写一段JavaScript代码,实现在当前页面加载完成后弹出一个宽高为640*480px的无工具栏、地址栏,但有
状态栏的浏览器窗口,并且弹出窗口在5秒钟后自动关闭。(10分)
2. 假设页面上有一个表单form1,包含如下元素:一个下拉框source,包括“File”,“DVD”两个选项,初始值
为“File”;一个文本域file_path,一个文本域dvd_label。 编写一段DHTML代码实现如下要求:当下拉框
source选定“File”时只显示文本域file_path,选定DVD时只显示dvd_label。(10分)

解决方案 »

  1.   


    function open() {
      var subWin = window.open ('page.html', 'newwindow', 'height=640, width=480, top=0,left=0, 
                     toolbar=no,location=no, menubar=yes,status=yes');
        setTimeout("close()",1000); 
    }function close() {
       subWin.close();
    }<body onload="open()">
      

  2.   

    函数命名改一下,openWin(),closeWin()
      

  3.   

    <!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=windows-31j">
    <title>Insert title here</title>
    <script type="text/javascript">
    /**
     * 第一题 
     */
    function runCode(value) {    var winName = window.open('', "_blank", 'height=640,width=480,status=yes,toolbar=no,menubar=no,location=no');
        winName.document.open('text/html', 'replace');
        winName.document.write(value);
        winName.document.close();
    }/**
     * 第一题 
     */
    function createCloseWindow() { var scriptHtml = "<html>";
    scriptHtml += "<head>";
    scriptHtml += "<script type='text/javascript'>";
    scriptHtml += " setTimeout(function() {window.close();}, 5000);";
    scriptHtml += "<\/script>";
    scriptHtml += "<\/head>";
    scriptHtml += "<\/html>"
    runCode(scriptHtml);
    }/**
     * 第二题 
     */
    function changeSelect(selectTarget) {

    if (selectTarget.selectedIndex == 0) {
    document.getElementById('file_path').style.display = '';
    document.getElementById('dvd_path').style.display = 'none';
    } else {
    document.getElementById('file_path').style.display = 'none';
    document.getElementById('dvd_path').style.display = '';
    }
    }</script>
    </head>
    <body>
    <input type="button" value="test" onclick="createCloseWindow();"><br />
    <select onchange="changeSelect(this);">
    <option>File</option>
    <option>DVD</option>
    </select>
    <span id="file_path">file_path</span>
    <span id="dvd_path" style="display:none;">dvd_path</span>
    </body>
    </html>