clubmate.fi

A good[ish] website

Web development blog, loads of UI and JavaScript topics

How to open a popup window with jquery

Filed under: JavaScript— Tagged with: popup, snippets

Generally popups are considered bad-ish, but sometimes they’re handy. For example when opening an audio player.

The following expects you to have the following HTML:

<a class="popper" html="#">Pop it</a>
$(function () {
  $('.popper').click(function () {
    var href = $(this).attr('href')
    window.open(href, 'popup', 'height=500,width=400,toolbar=no')

    return false
  })
})

This will give you a pop-up window 500px tall and 400px wide.

Source

Comments would go here, but the commenting system isn’t ready yet, sorry.

  • © 2022 Antti Hiljá
  • About
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • I love u!