jquery 修改iframe src
author liuqing
?
$('#username').attr("src","http://www.dangdang.com");
?
?
修改iframe 对应的内容
?
json tree 添加链接格式 "attributes":{"url":"usermanager/add.action"}
添加链接
?
[{ "id":1, "text":"Folder1", "iconCls":"icon-save", "children":[{ "text":"File1", "checked":true },{ "text":"Books", "state":"open", "children":[ { "text":"PhotoShop", "checked":true , "attributes":{ "url":"http://www.dangdang.com" } } ] }] },{ "text":"Languages", "state":"closed", "children":[{ "text":"Java" , "attributes":{ "url":"http://www.dangdang.com" } },{ "text":"C#" }] }]
?
实现代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@taglib prefix="sx" uri="/struts-tags-zk" %><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><sx:head/><script type="text/javascript">$(function(){$('#username').css({height:$(window).height()- 30});$('#tt22').tree({ url:'data.json', animate:true, onClick:function(node) { var url = node.attributes.url; if (url) { $('div.datagrid-mask').css({ height:$(window).height(), display:"block"}); $('div.datagrid-mask-msg').css({ left:$(document.body).outerWidth(true) / 2, top:$(window).height()/2 - 20, display:"block" }); $('#username').attr("src",url); clear(); } }});});function clear() {//这时使用 load(function{});//当加载成功后就动行function() $('#username').load(function(){$('div.datagrid-mask').css({display:"none"});$('div.datagrid-mask-msg').css({display:"none"});});}</script><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><div style="display:none;width:100%"></div><div style="font-size:12px;margin:auto;text-align:center;">正在加载</div><ul id="tt22"></ul><iframe id="username" frameborder="0" src="http://www.baidu.com" style="width:100%;height:100%;"></iframe></body></html>
?
?