简体   繁体   English

如何在图像上打开的窗口中单击以获取按钮,而不是调用该功能

[英]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.

相关问题 如何在单击链接时打开新选项卡或窗口? - How can I open a new tab or window when a link is clicked? 当使用html和css单击按钮图像时,如何使用按钮图像获取按钮图像源 - how can I use button images to get the button image source when they are clicked using html and css 单击按钮后,如何在发送ajax之前调用我的validate函数? - How can I call my validate function before sending my ajax when a button is clicked? 如何在点击打开灯箱库时链接按钮? - How can I link a button when clicked to open a lightbox gallery? 单击按钮时如何打开相同的选项卡 - How can I open the same tab when a button is clicked 如何在更改值而不是单击按钮时运行函数? - How can I make my function run when a value is changed instead of when the button is clicked? 当仅在新窗口中使用javascript并在同一选项卡中使用另一个javascript单击单选按钮时,如何打开多个网页 - How can I open multiple webpages when radio button is clicked using only javascript one in new window and other in same tab 我如何获得与html输入按钮关联的图像以在单击时更改 - How can I get image associated with html input button to change when clicked 单击按钮后如何更改图像 - How do I get the image to change when the button is clicked 获取图像的来源并在单击时在新窗口中打开 - Get the Source of an image and open in a new window when clicked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM