How can I open an image in a new window by using its id
?
function swipe()
{
var largeImage = document.getElementById('largeImage');
largeImage.style.display = 'block';
largeImage.style.width=200+"px";
largeImage.style.height=200+"px";
}
This function is called on click on the image. Right now, it's opening in the same window, but I want to open it in a new window. How can this be accomplished?
Using the keyboard shortcut Simply hold the ctrl and the alt/option key and left click on the image you would like to open in a new tab.
Opening a New Window in Your Browser. Locate and click the File option in your browser menu. This is generally at the top of your browser window. Select New Window .
For a new window that has a good chance of being lost behind the main window, and generally annoying visitors:
window.open('http://example.com/someImage.png');
I'd just stick to a regular link if I were you.
HTML:
<input type="button" onclick="test()" value="test">
JavaScript
function test(){
url = "https://www.google.de//images/branding/googlelogo/2x/googlelogo_color_272x92dp.png";
img = '<img src="'+url+'">';
popup = window.open();
popup.document.write(img);
popup.print();
}
Try this: https://jsfiddle.net/ne6f5axj/10/
You have to put the url of image in an image-tag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With