我想使用下面包含在函数调用中的代码显示图像。使用Javascript调用函数时出现图像显示错误
myWindow.document.write("<center><img border='2' src='../images/autumn/0216.jpg' width='120' height='90' /></center>");
当你明确地设置src细节例如src = '../images/autumn/0216.jpg'
并且图像显示正确。我需要做的是将图像的url发送到函数,以便我可以显示任何需要的图像(这是函数名称中的'照片'参考)。函数名称如下:
function photoorder(category, reference, photo)
我试图发送图像URL '../images/autumn/0216.jpg'
的函数调用,在接收和格式正确无误。但是当我使用命令src = photo
时,图像不显示。例如
myWindow.document.write("<center><img border='2' src='photo' width='120' height='90' /></center>");
或
myWindow.document.write("<center><img border='2' src=photo width='120' height='90' /></center>");
这工作正常。非常感谢。这是我没有尝试的唯一组合。 – 2013-05-11 10:42:02