页面显示客户端本地图片。 希望以以下方式实现。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图片。 求一个js效果 这代码怎么使firefox兼容 图片循环滚动求助 可以用javascript写这样的一个onload事件吗 如何判别注册用户是否为新的.或者是已经注册的. 延迟加载问题 如何截取字符串?比如得到第四到第六个 如何在用户关闭IE时执行session.abandon事件? ***&&&一個二級聯動菜單問題,問題是很簡單,可是一定要看完所有的信息,不要憑藉以前的經驗?? 在一个页面中点击一个按钮打开另外一个窗口,并使这个窗口是从屏幕的上到下移动呢?在原来那个页面点击按钮把打开的那个窗口关闭!应该怎么 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图片。