0
How do I link to a modal window? In case I want to send this link, the user by clicking on the link already open direct the modal. How do I do that?
0
How do I link to a modal window? In case I want to send this link, the user by clicking on the link already open direct the modal. How do I do that?
2
Pass a parameter through the link:
example: http://dominio.com/nome_pagina_modal.html?par=open
In your application put this script (conditional operator (ternary)):
location.href.split("=").pop() == "open" ? $('#bannerformmodal').modal('show') : null;
location.href;
returns the URL of the current pagesplit("=").pop();
picks up the part after the =Operador Ternário
- if the condition location.href.split("=").pop() == "open"
is true, the operator will return the value $('#bannerformmodal').modal('show')
if no, it returns the value null;
.0
One option is to use hashtag
to inform that the client wants to open a modal
, example:
www.sitedevendas.com/product#buy
That way you would know that the client wants to open the modal
buy and so you should analyze in window.location.href
if there is #comprar
in that string.
$(document).ready(function() {
if(window.location.href.indexOf('#comprar') != -1) {
$('#comprar').modal('show');
}
});
Browser other questions tagged javascript twitter-bootstrap modal
You are not signed in. Login or sign up in order to post.
Or rather, you don’t need to convert Location.href into string, because it is already string. You can delete a line there.
– Sam
var parametro = (Location.href). split("="). pop();
– user60252
Aha.. put in the functional example for us to see
– Sam
@Fucking posted on the server
– user60252
Only the.. rsss.. was much better in my opinion
– Sam
20 lines left only 1 rsrs
– Sam