免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4363 | 回复: 3
打印 上一主题 下一主题

请问html如何使用条件语句 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-10-26 18:14 |只看该作者 |倒序浏览
比如我有一个链接,和一个复选框

如果选中复选框,则点击链接是刷新本页,如果没有选中复选框,则是弹出新窗口。

请问这个好实现吗?

论坛徽章:
0
2 [报告]
发表于 2007-10-26 18:51 |只看该作者
不是用HTML,是用JAVASCRIPT

论坛徽章:
0
3 [报告]
发表于 2007-10-26 20:09 |只看该作者
请问JS应该怎么写呢?能帮忙举个例子吗?谢谢了。

论坛徽章:
1
申猴
日期:2014-12-23 16:52:51
4 [报告]
发表于 2007-10-27 10:09 |只看该作者
刚刚做了个代码如下:
文件名:test.htm

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <title>刷新测试</title>
  6. </head>

  7. <body>
  8. 测试内容
  9. <form id="form1" name="form1" method="post" action="">
  10.   <input name="newwin" type="checkbox" id="newwin" value="newwin" />
  11.   <select name="select">
  12.   </select>
  13.   
  14.   在新窗口中打开
  15.   <input type="button" name="Submit" value="刷新数据" onclick="check()"/>
  16. <?php echo date("H:m:s"); ?></form>
  17. </body>
  18. </html>
  19. <script language="JavaScript" type="text/javascript">
  20. function newwindow(theURL,winName,features)  //打开新窗口()
  21. {
  22.          newwinname=window.open(theURL,winName,features);
  23.          if(!newwinname.closed)//判断窗口是否在最前面
  24.          {
  25.                 newwinname.focus();//把新打开的窗口放到最前面
  26.          }         
  27. }

  28. function MM_goToURL() { //转到新页面('parent','delete_stock.php?ty=1')
  29.   var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  30.   for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
  31. }

  32. function check()//检查程序
  33. {
  34. if(document.forms['form1'].elements['newwin'].checked==true)//判断是否选中
  35. {
  36. newwindow('test.htm','test','status=yes,scrollbars=yes,resizable=yes,width=600,height=400,left=250,top=200');//如果选中 在新窗口中打开
  37. }
  38. else
  39. {
  40. MM_goToURL('parent','test.htm');//如果没有选中就在本面打开
  41. }

  42. }
  43. </script>
复制代码


你看下是否是你想要的结果
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP