Open new window and set new url - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window open

Description

Open new window and set new url

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <a href="#" onclick="javascript:share();"> 
         <span>Share on Facebook</span> 
      </a> 
      <script>
   function share() {/*from ww  w .j  a  v a  2s  . c om*/
      window.open(
      "https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(location.href),
      "facebooksharedialog",
      "width=626,height=436");
      return false;
   }

      </script>  
   </body>
</html>

Related Tutorials