喜逢身体我想通过点击一个按钮,在新窗口中打开图像,使用JavaScript,然后设置一个类的图像打开一个元素,使用此代码:我不能在一个类分配给新的窗口
OpenWindow=window.open("", "newwin","height=100,width=1000");
OpenWindow.document.write("<img id='img1' src='webfonts.jpg'>");
OpenWindow.document.getElementById("img1").className = "larger";
OpenWindow.document.close();
,这是内部样式我已经包含在我在样式标记代码: .larger {宽度:10px的; } 和在身体标记 1:我具有由IMG标签包括我的图像源 2:使一个按钮标签与一个onclick =较大()属性
但不幸的是我与最后一个句子中的问题,该班级根本没有分配给图像。 我曾尝试使用classname而不是setttribute,但它会生成相同的结果。 有什么想法? thx
你忘了包括代码:)添加它,选择它,然后单击1和0的按钮对其进行格式化:) – 2010-08-01 10:59:41
见http://stackoverflow.com/questions/2490627/how-can-i-reliable-set-the-class-attr-w-javascript-on-ie-ff-chrome -etc – 2010-08-01 11:02:25
当然,我已将图像源以这一行写入新窗口: OpenWindow.document.write(“”); – loll 2010-08-01 11:06:24