if a user opens a modal box and clicks the back button in the browser window he should stay on the same site. eBay is a good example: http://www.ebay.de/itm/NIKE-FLEECE-JOGGINGHOSE-HOSE-CUFFED-SWEATHOSE-TRAININGSHOSE-FREIZEITHOSE-/380751278122?pt=LH_DefaultDomain_77&var=&hash=item58a68b702a
If you click on the image the modal opens and if you click the back button of your browser you stay on the same page instead of redirecting to the previous page.
How can i do this with jQuery that the user stays in the same window if he clicks the back button in his browser ?
This is my modal code
/**
* Will be called when the detail page image slider was clicked..
* Opens the lightbox with an image slider clone in it.
*
* @event onClick
*/
onClick: function () {
var me = this,
plugin = me.$el.data('plugin_imageSlider');
$.modal.open(me.$template || (me.$template = me.createTemplate()), {
width: '50%',
height: '50%',
padding: '20px',
animationSpeed: 350,
additionalClass: 'image-gallery--modal no--border-radius',
onClose: me.onCloseModal.bind(me)
});
me._on(me.$zoomInBtn, 'click touchstart', $.proxy(me.onZoomIn, me));
me._on(me.$zoomOutBtn, 'click touchstart', $.proxy(me.onZoomOut, me));
me._on(me.$zoomResetBtn, 'click touchstart', $.proxy(me.onResetZoom, me));
picturefill();
me.$template.imageSlider({
dotNavigation: false,
swipeToSlide: true,
pinchToZoom: true,
doubleTap: true,
maxZoom: me.opts.maxZoom,
startIndex: plugin ? plugin.getIndex() : 0,
preventScrolling: true
});
me.toggleButtons(me.getImageSlider());
},
/**
* Will be called when the modal box was closed.
* Destroys the imageSlider plugin instance of the lightbox template.
*
* @event onCloseModal
*/
onCloseModal: function () {
var me = this,
plugin = me.getImageSlider();
if (!plugin) {
return;
}
plugin.destroy();
},
Now if the user clicks the browser back button the modal should close but the user should stay on the SAME site.