Opening a modal from a different page

I would like to find out how a modal in a different page can be opened from a separate page

Not sure what you’re trying to do here, or if you’re creating a problem where no problem exists.

If you’re on your home page and you want to click a button while you’re on the home page and have it open a modal that’s on your “contact us” page, then simply copy the modal component that is on your “contact us” page to your “home page”, and then you can open it.

You can have the same modal with the same ID on multiple pages.

Having issues working on the backend, so thought it would be better having the modal on separate page. but I get your point. I think will need to work out on the same rather than getting it on a separate page. Thanks!

Or easier yet, just link to the page and use an anchor tag to take people directly to the location of the model on the page (if it’s further down the page that is). Truly it’s just loading one more page and most mobile devices can handle that these days pretty easily.

1 Like

You can have your modals in a javascript function and show it from any page. Then you can also manipulate the content of the modal if you need to

2 Likes

If I understand your inquiry correctly then from a specific link to the other page you could use javascript to set a localStorage() via setItem(). Or through various other approaches such as by adding a hash as part of the url you are opening, etc.

When the other page loads use a load event to read your chosen logic. If via localStorage() then use getItem() and if the key is detected open the modal popup. After you call the modal to open simply removeItem() or clear() from the localStorage().

If its scripted and managed properly through javascript then from all other links to that page the modal would not open, but if you want that you can do that as well. Plus you have the opportunity to control everything if desired.

1 Like

You could also forgo the standard Bootstrap modal and create one in pure CSS which could be called from any page. I have an old, non-responsive website where I used such a technique. You can click the “request a quote” in the upper right and it opens the same modal no matter what page you’re on.

any help on how to use this function:

Like where do i go from here:

$("#formCheck-1").click(function(){
$.post(‘Modal.html’)
$("#time").modal(“show”);
});

here are some examples

2 Likes