主页面中嵌套了iframe,想把请求的结果传入到iframe中。但我不想用session,有什么办法能够把request.setAttribute("info",info);的值传递给iframe么。感觉iframe是第二个页面一样,request只能将值传递给主页面
试试下面代码:
[code="HTML"]
var list = [ <% List list = (List) (request.getAttribute("promotionlist")); for (Iterator it = list.iterator; it.hasNext();) { out.print("\"" + it.next() + "\""); if (it.hasNext()) out.println(", "); } %> ]; document.getElementById("iframeContent").promotionList = list;[/code]
然后到iframe页面,从iframe中取值
[code="JavaScript"]
var list = window.top.frames["promotionlist"].promotionList;
[/code]
父页面
[code="js"]
String str = (String)request.getAttribute("info");
[/code]
frame.html页面,将info的值从url中解析出来就行了
[code="js"]
alert(window.location);
alert(window.location.href);
[/code]