在2.htm中设置Cookie <script> function setCookie() { var the_name = prompt("What's your name?",""); var the_cookie = "wm_javascript=username:" + escape(the_name); var the_date = new Date("December 31, 2023");//此日期可自行修改 var the_cookie_date =the_date.toGMTString(); the_cookie = the_cookie +";expires=" + the_cookie_date; document.cookie = the_cookie; alert("Thanks, now go to the nextpage.");} </script> <input type=button value="设置Cookie" onclick=setCookie()>在1.htm中读取Cookie <script> function readCookie(){ var the_cookie = document.cookie; var broken_cookie = the_cookie.split(":"); var the_name = broken_cookie[1]; var the_name = unescape(the_name); alert("Your name is: " + the_name);} </script> <input type=button value="读取Cookie" onclick=readCookie()>
<script>
function setCookie()
{ var
the_name = prompt("What's your name?",""); var the_cookie =
"wm_javascript=username:" + escape(the_name);
var the_date = new Date("December 31, 2023");//此日期可自行修改 var the_cookie_date =the_date.toGMTString(); the_cookie = the_cookie +";expires=" + the_cookie_date; document.cookie =
the_cookie; alert("Thanks, now go to the nextpage.");}
</script>
<input type=button value="设置Cookie" onclick=setCookie()>在1.htm中读取Cookie
<script>
function readCookie(){ var the_cookie = document.cookie; var broken_cookie = the_cookie.split(":"); var the_name = broken_cookie[1]; var the_name = unescape(the_name); alert("Your name is: " + the_name);}
</script>
<input type=button value="读取Cookie" onclick=readCookie()>
我想在2.htm中操作后,要在1.htm中显示2.htm返回的值;
用cookic不能实现;
在1.htm用showModalDialog打开2.htm,
由于我用的2.htm比较复杂;
返回的是一个对象(我只是引用,不知具体),而不是我要的值,
通过ALERT可以显示我要的值;但不知怎么给1.htm;
用top.document.id.value="value"或
parent.document.id.value="value",报错top.document.id不是对象???
我觉得用showModalDialog是可以解决你的问题的
在2.htm用window.returnValue把你要的值返回,就是有很多个值要返回也可以的办到的
我调用EXCHANGE的查找用户功能,
在1.htm中用showModalDialog
打开2.htm(其实我不知2.htm内容,只是一个URL,是个黑匣子,它指向其他地方),
我在一个2.htm的JS文件中找到一个FUNCTION可显示我要的数据,
通过ALERT可以显示我要的值,
用window.returnValue,
返回[OBJECT];但不知怎么给1.htm;