Enlace URL directo a la ventana emergente Modal (SimpleModal)

Is there a way to have a direct URL link to a modal popup using SimpleModal? What I mean is that if I go to that URL, the modal would be already popped up.

preguntado el 09 de septiembre de 13 a las 04:09

2 Respuestas

In case you only want the modal to show when users come from a specific referring url, this will work:

$(document).ready(function () {
    var pathname = $(location).attr('href');
    if (pathname.indexOf("modalA") >= 0) {
        $('#modalA').show();
    }
});

and this for when you want different referring urls to open different modals:

$(document).ready(function () {
    var pathname = $(location).attr('href');
    if (pathname.indexOf("modalA") >= 0) {
        $('#modalA').show();
    }
    else if (pathname.indexOf("modalB") >= 0) {
        $('#modalB').show();
    }
    else {
        $('#modalC').show();
    }
});

Respondido 23 Oct 13, 22:10

You need to open the modal on load of the window. As per the document your have provided, I think the following should work. This code should be written in the document which URL you are going to open.

window.onload=function(){
$("#element-id").modal();
};

Respondido el 09 de Septiembre de 13 a las 06:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.