JavaScript code modified for backwards compatibility and added checking
for blocked popups.

Change-Id: Ic600d3404a4bee6ba1f5a256c8a9248b7d1a71db