Call modal via url

0

I have a page where there is a Modal of register, I have to call this modal from an external page, preferably by url , I would like to know if it is possible and if they can indicate the way to me

  

NOTE: Modal can not be enabled directly on the page, and this page uses Bootstrap to generate Modai's .

    
asked by anonymous 12.02.2015 / 14:07

1 answer

1

To read the query string (GET) in a URL you can do a function like this:

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\[").replace(/[\]]/, "\]");
    var regex = new RegExp("[\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

In this case if you have a url minhapagina.html?modal=true then getParameterByName('modal) var give true .

This function fetched to Soen but you may not need something like this, if the URL that activates the modal does not have key / value pairs and only ?modal or nothing; then a .indexOf() is enough.

In this case you can use% location.search.indexOf('modal') != -1 that will give true ( true ) if the "modal" word exists in the ?xxxx of the url.

    
12.02.2015 / 17:38