In the last episode of the third season of Star Trek: The Next Generation (look up the stardate yourself, ya big nerd) the pseudoscientists who kept an eye on the (admittedly flakey) physics behind the series did something clever - they introduced a new ability of the transporter and, unbelievably, didn't make a big 'ooh! Look what we can do now!' -type scene out of it. Through one line of dialogue (this node's title, coincidentally), the writers added the ability to transport between two ships travelling at warp speed. It's also one of the few times they managed to stick to the science they created for the rest of the franchise's run.
In the Original Series, the transporter could only be used to get from a ship to a planet's surface or from ship to ship if both vessels were more or less stationary (ie at sublight/impulse speeds or, ideally, at relative rest) and this usage held true until a remarkably talented transporter chief with, as it turned out, a long and established career ahead of him, used the transporter to get an away team onto a speeding Borg cube in an attempt to rescue Captain Picard from Borgification.
The trick is to precisely match the velocity of the target ship and to get as close as safely possible so that a. the transporter's targetting sensors have something relatively stationary to lock onto (remember that an increase from warp 9.6 to warp 9.7 increases a starship's velocity by a factor of ten or so) and b. so that the molecules of the target don't end up in a violently different arrangement when they arrive on the pad - If the ships are moving at different speeds and their warp fields aren't in contact (that last clause is a supposition on my part - it's never implicitly mentioned but it makes sense, so...) the transporter beam and its occupant will leave the ship's warp field, drop to light speed and instantly be overtaken by its destination moving at hundreds or thousands of times the speed of light. Whatever DOES make it to its destination will look less like your beloved captain and more like...well, use your imagination.
The advantage to this, from the writers' perspective, is that it's so easy to get right - all they need to do is insert the line "matching warp velocity for transport" before the transport and the physics stays as intact as technobabble can possibly be. Gave O'Brien something to say every once in a while, too.