0

I have a webpage with an url to PHP file which displays picture. I want to open this picture in new window without blank page.

For now with code below, when I click on URL, blank page and new window open (which I have to close each time). I do not want this blank page, only window with picture

window.open('image.PNG', 'image', 'toolbar,menubar,scrollbars,resizable,height=800,width=400,left=600,top=400');

How to do it?

//edit Prevent default does not work if I have

<a href="file.php">Link</a> //URL to PHP with script above
Michal Bialek
  • 499
  • 1
  • 10
  • 26

1 Answers1

0

If you paste this in your console:

open('image.png');

And a new tab opens with the picture you want, than try:

<a href = 'image.png' id = 'image'>

and

document.getElementById('image').onclick = funciton(e){
    e.preventDefault();
    open('image.PNG', 'image', 'toolbar,menubar,scrollbars,resizable,height=800,width=400,left=600,top=400');
};

If that doesn't work, paste this in your console:

open('file.php');

And a new tab opens with the picture you want, than try:

<a href = 'file.php' id = 'file'>

and

document.getElementById('file').onclick = funciton(e){
    e.preventDefault();
    open('file.php', 'image', 'toolbar,menubar,scrollbars,resizable,height=800,width=400,left=600,top=400');
};

If none of that works, comment below.