<HTML>
<Head>
<title>Explorer 用户提示</title>
<body>
<script language="JavaScript">
function pushbutton()
{
test=window.prompt("URL地址");
}
</script>
<img src="images/insertimage.gif" alt="插入图片" onclick="pushbutton()">
<script language=javascript>
document.write(test);
</script>
</body>
</Head>
</HTML>echo后会变成这个样子,也就是说函数pushbutton还没调用即test还没有被赋值时就执行了document.write(test),自然没有数据
直接把document.write(test)加在test赋值语句后就行了
function pushbutton()
{
test=window.prompt("URL地址");
document.write(test);
}
不过用document.write会清除原有文档内容

解决方案 »

  1.   

    谢谢he1a2s0(飞鼠) 不过这个不是我想的效果 不知能不能加入QQ:15131180 这样方便联系一下
      

  2.   

    我现在就是想用PHP来提取test数据 然后想存入数据库中 不过无法得到实现
      

  3.   

    那可以用隐藏表单域
    页面加一个
    <form action="target.php" method="post" id="frm1" name="frm1">
    <input type="hidden" name="url" id="url" value="">
    </form>
    把document.write(test)换成document.forms["frm1"].elements["url"].value=test
    加一句自动提交document.forms["frm1"].submit();
    应该就可以了,现在在target.php里面就可以对test为所欲为了哈哈!