HTML How do I open this URL in a new window?

This is the code:

<a href="FAKE_URL" onclick="document.location.href = 'REAL_URL'; return false;">
<img src="IMAGE"></a>

      

I've already tried:

<a href="FAKE_URL" onclick="document.location.href = 'REAL_URL'; return false;" target="_blank">
<img src="IMAGE"></a>

      

but doesn't work

+3


source to share


3 answers


Try the following:



<a href="../html-link.html" target="popup" onclick="window.open('../html-link.html','name','width=600,height=400')">Open page in new window</a>

      

+1


source


you can use to open after next tab onclickevent: window.open('url','_blank')

<a href="https://google.com" onclick="window.open('https://youtube.com','_blank'); return false;">click here for a new tab</a>

      

or you can use to open a new window: window.open('url','','width=,height=')

<a href="https://google.com" onclick="window.open('https://youtube.com','','width=800,height=700'); return false;">click here for a new window...</a>

      

In this example, it will open youtube ( REAL_URL

) instead of google ( FAKE_URL

)



> JSFiddle - Example


Explanation:

Your mistake was that the addition changes the behavior of yours , but not yours . So without it it will open in a new tab. target="_blank"

<a href="..."></a>

document.location.href='...'

document.location.href='...'

FAKE_URL

+1


source


To open the file in a new window use

onclick="window.open('yourfile.html','','width=750px,height=1000px,left=150,top=β€Œβ€‹0,toolbar=no,status=no,resizable=no,titlebar=no').focus();"

      

0


source







All Articles