How to do for when I click button,open link in another window

Asked

Viewed 17,549 times

1

example this image below,I clicked the button and open in a small window! veja a imagem

2 answers

3

<a href="#" onClick="window.open('pagina.html','pagename','resizable,height=260,width=370'); return false;">Clique aqui</a><noscript>Você precisa estar com o javascript ativado, caso contrário <a href="pagina.html" target="_blank">clique aqui</a></noscript>
  • thanks friend!!

  • the more you’re opening my own website?

  • how do I open another?

  • in place of pagina.html you can specify a url address

  • 1

    ok vlw!! Mt thank you

  • The location where you specify the desired address is in the attribute href, of the element <a>...

  • @Magichat, the new window opens using javascript. That’s why # within the href. In this case, you need to specify inside the onclick itself. This way, you can test in the browser as follows: window.open('http://www.google.com','pagename','resizable,height=260,width=370');

  • friend,now here another question,how do I apra when I close that screen,the page update alone?

  • @Ronnyamarante the two forms, are correct, depending on the organization of the project, one will be the best option.

  • @Magichat, I made a test here to show you. Take a look, pls: http://jsbin.com/lonipasoco/edit?html,output

  • @Ronnyamarante what exactly you wished to show ?

  • @Magichat; which prevails. Mainly because you will never apply this inline. If your js has not been loaded, it will just forward to href without opening in a new window.

  • @Ronnyamarante veja a edição que fiz na minha resposta, na parte do javascript, onde uso this.href and understand my point of view.

  • @Magichat; If js is not enabled you don’t need fallback noscript, in your case it will open in a new tab the content. If the JS has not yet been loaded, it will open in a new tab, not following the proposal of the question. In your code I see no need to noscript and you?

  • @Ronnyamarante No, there is no need, it is even better. It is explained, why the href be a better way, in my view... "Socratic" method always works, for both involved... vlw, man ;)

Show 10 more comments

0

Take this example :

<!DOCTYPE html>
<html>
<body>

<a href="http://www.w3schools.com/html/" target="_blank">Visit our HTML tutorial!</a>

<p>Se você colocar o valor do atributo "target" como "_blank", o link abrirá uma nova janela</p>

</body>
</html>

And to specify the size use Javascript

<a href="/questions/157601/como-fazer-para-quando-eu-clicar-bot%C3%A3o-abrir-link-em-outra-janela" onClick="window.open(this.href,'pagename','resizable,height=260,width=370'); return false;">Nova Página</a>

Source OS

Browser other questions tagged

You are not signed in. Login or sign up in order to post.