<span style="color:#ff0000;">//login.html页面</span>
<!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=utf-8" /> <title>无标题文档</title> <script src="jquery-1.8.3.min.js" type="text/javascript"></script> <script src="jquery.cookie.js" type="text/javascript"></script> <script> $(document).ready( function(){ $("#btnOk").click( function(){ //存放刚才的zhang.laoshi信息; //$.cookie('user',$("#user").val()); //user:存放信息key;value //alert($("#meiniu").attr("src")); $.cookie('src',$("#meiniu").attr("src")); } ); } ); </script> </head> <body> <form id="form1" name="form1" method="post" action="success.html" ><!--action提交到某个页面;get:提交方式?user='zhang' and pwd='123'--> <table width="800" border="0" align="center"> <tr> <td width="65">用户:</td> <td width="613"><input type="text" name="user" id="user" /></td> <td width="108"> </td> </tr> <tr> <td>图片</td> <td><img src="meiniu.jpg" width="118" height="79" id="meiniu" /></td> <td> </td> </tr> <tr> <td><input type="submit" name="button" id="btnOk" value="提交" /></td> <td><input type="reset" name="button2" id="button2" value="重置" /></td> <td> </td> </tr> </table> </form> </body> </html>
//2.提交之后的success.html页面
<!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=utf-8" /> <title>无标题文档</title> <script src="jquery-1.8.3.min.js" type="text/javascript"></script> <script src="jquery.cookie.js" type="text/javascript"></script> <script> $(document).ready( function(){ //显示到div里面; //$("#content").html($.cookie('user')); //html:相当于div的innerHTML var s=$.cookie('src'); $("#meiniu").prop("src",s); } ); </script> </head> <body> <div id="content" style="border:1px solid #f00; width:600px; height:300px;"> <img id="meiniu" src="" width="118" height="79"/> </div> </body> </html>