[英]How can I get my button when clicked in an window open on an image to work it is not calling the function
I have a function that gets an image along with it's height and width. 我有一个功能,可以获得图像的高度和宽度。 I open the image in a new window using window.open I defined an
onclick
so that if anyplace on the image is clicked the window closes, this works fine. 我使用window.open在一个新窗口中打开图像我定义了一个
onclick
这样如果单击图像上的任何位置,窗口关闭,这可以正常工作。 I have defined a button and located it outside the image in the new window. 我已经定义了一个按钮,并将其定位在新窗口中的图像外部。 When that button is clicked it calls another function, this does not work.
单击该按钮时,它会调用另一个函数,但这不起作用。 Is there away to make this work?
有没有让这项工作?
I have tried several different ways of making this work. 我已经尝试了几种不同的方法来完成这项工作。 I have tried removing the close when clicking on the image and that did not work.
我已经尝试在单击图像时删除关闭但不起作用。 I have tried putting the button on the image and that did not work.
我试过把按钮放在图像上但是没有用。
function showImg(imgSrc, H, W) {
newImg = window.open("", "", config = "height=" + H + ",width=" + W + "");
newImg.document.write("<img src='" + imgSrc + "' height='" + H + "' width='" + W + "'class=photoPreview onclick='window.close()' style='position:absolute;left:0;top:0'>");
newImg.document.write('<input type="button" id="btn_makedefault" onclick=saveMe(); style="color: black; position: absolute; left: 0; bottom: 0";title="Save Image"; value="Save"></button>');
newImg.document.close();
newImg.focus();
}
I want the Save button to remain at the bottom of the window and when clicked to call the other function saveMe(). 我希望“保存”按钮保留在窗口的底部,并在单击时调用另一个函数saveMe()。
Change the onclick=saveMe(); 更改onclick = saveMe(); to onclick="opener.saveMe()";
to onclick =“opener.saveMe()”; and that appears to work just the way I need it to work.
这似乎只是我需要它工作的方式。 Thanks for all the help.
谢谢你的帮助。
''' function showImg(imgSrc, H, W) { newImg = window.open("", "", config = "height=" + H + ",width=" + W + ""); '''函数showImg(imgSrc,H,W){newImg = window.open(“”,“”,config =“height =”+ H +“,width =”+ W +“”); newImg.document.write("");
newImg.document.write( “”); newImg.document.write('');
newImg.document.write( ''); newImg.document.close();
newImg.document.close(); newImg.focus();
newImg.focus(); } '''
}'''
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.