页面显示客户端本地图片。 希望以以下方式实现。div.innertHTML="这里是文字,<img />,文字文字 ";文字围绕图片显示。HTML代码如何写? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <div id="div" style="text-align:center;">a</div><script>var div=document.getElementById("div");div.innerHTML="青龙<br />玄武<img />朱雀<br />白虎";</script> function maker(tag) { return function(attributes, children) { if (arguments.length == 1) return make(tag, attributes); else return make(tag, attributes, children); } } function make(tag, attributes, children) { var root = document.createElement(tag); if(arguments.length == 2 && attributes.constructor != Object) { children = attributes; attributes = null; } if(attributes) { for(var name in attributes) { if(attributes[name] == attributes.className) root.className = attributes[name]; else root.setAttribute(name, attributes[name]); } } if(children) { if(children.constructor == String) { root.appendChild(document.createTextNode(children)); } else if(children.constructor == Array) { for(var i = 0; i < children.length; i++) { if(children[i].constructor == String) children[i] = document.createTextNode(children[i]); root.appendChild(children[i]); } } else { root.appendChild(children); } } return root; } var div = maker("div"), maker("img"); var myRoot = div(["这里是文字,", img({width : 50, height : 50}),",文字文字"]); document.body.appendChild(myRoot); 如果不行加上window.onload试试,这个还可以这么玩: window.onload = function() { function maker(tag) { return function(attributes, children) { if (arguments.length == 1) return make(tag, attributes); else return make(tag, attributes, children); } } function make(tag, attributes, children) { var root = document.createElement(tag); if(arguments.length == 2 && attributes.constructor != Object) { children = attributes; attributes = null; } if(attributes) { for(var name in attributes) { if(attributes[name] == attributes.className) root.className = attributes[name]; else root.setAttribute(name, attributes[name]); } } if(children) { if(children.constructor == String) { root.appendChild(document.createTextNode(children)); } else if(children.constructor == Array) { for(var i = 0; i < children.length; i++) { if(children[i].constructor == String) children[i] = document.createTextNode(children[i]); root.appendChild(children[i]); } } else { root.appendChild(children); } } return root; } var table = maker("table"), tbody = maker("tbody"), tr = maker("tr"), td = maker("td"); var myTable = table({width : 400, align : "center", cellPadding : 0, cellSpacing : 1, border : 0, bgColor : "#000000"}, tbody([tr({height : 25, align : "center", vAlign : "middle", bgColor : "#FFFF00"}, td({colSpan : 5}, "课程表")), tr({height : 25, align : "center", vAlign : "middle", bgColor : "#FFFF00"}, [td("星期一"), td("星期二"), td("星期三"), td("星期四"), td("星期五")]), tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]), tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]), tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]), tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]), tr({height : 5, bgColor : "#FFFF00"}, td({colSpan : 5})), tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]), tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]), tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")])])); document.body.appendChild(myTable); } 首先放你的回复。我的意思:不要Js脚本,直接写出在页面上引用本地某个位置的(比如:c:/1.jpg)图片。所有的都在HTML代码里,或者CSS文件里。 解决:div.innerHTML="我这里是文字我这里是文字<img style='width:74px;height:95px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=" + PicPath + ")' src='images/null.png' id='img' hspace='5' vspace='5' align='right'/>我这里是文字我这里是文字我这里是文字我这里是文字我这里是文字我这里是文字";其中:PicPath 是本地路径。src是服务器上的图片路径,我这里用一个全透明的PNG图片。 用网页代码代替ftp上传文件,急急急 FusionCharts v3.0问题,调用第二次调用setDataURL报脚本错误 求鼠标点击修改表格单元的代码 求救:jQuery如何处理select事件? 求http://www.amazon.com.cn/ 所有19类商品 展开图层的代码 想挑战的师兄师姐们空余的时间进来看看吧 急!!!! 出现没有权限错误怎么办? 链接 关于try{}catch{}的简单问题 看了一个教程,神密的说这就是传说中的... checkbox 全选的问题 修改字体 那个是什么控件?
var div=document.getElementById("div");
div.innerHTML="青龙<br />玄武<img />朱雀<br />白虎";
</script>
function maker(tag) {
return function(attributes, children) {
if (arguments.length == 1) return make(tag, attributes);
else return make(tag, attributes, children);
}
}
function make(tag, attributes, children) {
var root = document.createElement(tag);
if(arguments.length == 2 && attributes.constructor != Object) {
children = attributes;
attributes = null;
}
if(attributes) {
for(var name in attributes) {
if(attributes[name] == attributes.className) root.className = attributes[name];
else root.setAttribute(name, attributes[name]);
}
}
if(children) {
if(children.constructor == String) {
root.appendChild(document.createTextNode(children));
} else if(children.constructor == Array) {
for(var i = 0; i < children.length; i++) {
if(children[i].constructor == String) children[i] = document.createTextNode(children[i]);
root.appendChild(children[i]);
}
} else {
root.appendChild(children);
}
}
return root;
} var div = maker("div"), maker("img");
var myRoot = div(["这里是文字,", img({width : 50, height : 50}),",文字文字"]);
document.body.appendChild(myRoot);
function maker(tag) {
return function(attributes, children) {
if (arguments.length == 1) return make(tag, attributes);
else return make(tag, attributes, children);
}
}
function make(tag, attributes, children) {
var root = document.createElement(tag);
if(arguments.length == 2 && attributes.constructor != Object) {
children = attributes;
attributes = null;
}
if(attributes) {
for(var name in attributes) {
if(attributes[name] == attributes.className) root.className = attributes[name];
else root.setAttribute(name, attributes[name]);
}
}
if(children) {
if(children.constructor == String) {
root.appendChild(document.createTextNode(children));
} else if(children.constructor == Array) {
for(var i = 0; i < children.length; i++) {
if(children[i].constructor == String) children[i] = document.createTextNode(children[i]);
root.appendChild(children[i]);
}
} else {
root.appendChild(children);
}
}
return root;
}
var table = maker("table"), tbody = maker("tbody"), tr = maker("tr"), td = maker("td");
var myTable = table({width : 400, align : "center", cellPadding : 0, cellSpacing : 1, border : 0, bgColor : "#000000"},
tbody([tr({height : 25, align : "center", vAlign : "middle", bgColor : "#FFFF00"}, td({colSpan : 5}, "课程表")),
tr({height : 25, align : "center", vAlign : "middle", bgColor : "#FFFF00"}, [td("星期一"), td("星期二"), td("星期三"), td("星期四"), td("星期五")]),
tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]),
tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]),
tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]),
tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]),
tr({height : 5, bgColor : "#FFFF00"}, td({colSpan : 5})),
tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]),
tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")]),
tr({height : 25, bgColor : "#FFFF00"}, [td(" "), td(" "), td(" "), td(" "), td(" ")])]));
document.body.appendChild(myTable);
}
首先放你的回复。我的意思:不要Js脚本,直接写出在页面上引用本地某个位置的(比如:c:/1.jpg)图片。
所有的都在HTML代码里,或者CSS文件里。
<img style='width:74px;height:95px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=" + PicPath + ")' src='images/null.png' id='img' hspace='5' vspace='5' align='right'/>我这里是文字我这里是文字我这里是文字我这里是文字我这里是文字我这里是文字";其中:PicPath 是本地路径。
src是服务器上的图片路径,我这里用一个全透明的PNG图片。