<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<script type="text/javascript"> var x="hello";
var y=2008;
var z=0;
z=(x+y==="hello2008")?'"alert("welcome to china")"':"we are still watting";
//alert("5+3=");
//confirm("asf");
// prompt("请输入你的名字","张三");
// document.write("hello");
// x="5"+(5+5)
document.write(z);
</script>
</body>
</html>想让alert在“”内生效 不知道该怎么写 求教,还是说这个alert 不能嵌套在“”内使用

解决方案 »

  1.   

    z=(x+y==="hello2008")?function(){alert("welcome to china");}:function(){document.write("we are still watting");};
    z();
      

  2.   

    谢谢提醒 
    我想要知道的是如何在“”内实现alert 
      

  3.   

    z=(x+y==="hello2008")?alert("welcome to china"):"we are still watting";
      

  4.   

    var a="alert(123);";
    eval(a);
      

  5.   

    zel1419  你回答的很不错, alert直接拿来使用就行了 谢谢提醒
    感谢 ifandui 提供的方法