Actually there is a straightforward way to change the behavior of all Graphics
objects (including those which do not go to the $Output
channel): simply to define
$DisplayFunction = ((theGraphic = #; #) &);
An alternative to Dynamic
solution is to use the second argument of CreateDocument
:
obj = CreateDocument[];
$DisplayFunction = ((CreateDocument[#, obj]; #) &);
Do[ListPlot[Prime[Range[n]], Filling -> Axis], {n, 25, 50}]