Jump to content
  • 0

How do I code a JavaScript pop up window


xarzu

Question

What is the best and easiest way to have a modal window pop up in JavaScript code?  I have a function in JavaScript where I would like to put a modal pop up window code in so what I know it is being hit.  I did a search engine search on the internet for examples of this but everything I found was accompanied with HTML and CSS code.  That is not what I am looking form.  Please advise.

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0
On 2/22/2018 at 7:28 AM, xarzu said:

What is the best and easiest way to have a modal window pop up in JavaScript code?  I have a function in JavaScript where I would like to put a modal pop up window code in so what I know it is being hit.  I did a search engine search on the internet for examples of this but everything I found was accompanied with HTML and CSS code.  That is not what I am looking form.  Please advise.

Hi Xarzu,

Try this code:

<script type="text/javascript">
// Popup window code
function newPopup(url) {
 popupWindow = window.open(
  url,'popUpWindow','height=300,width=400,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
</script>
<p><a href="JavaScript:newPopup('https:www.thenameofthepage.com');">Pop Up Window</a></p>
 

You may play around with the width and height of the popup window based on your desired display.

regards,

Franchiser

Link to comment
Share on other sites

  • 0

Do you want a modal or a popup? You can easily make a modal menu with HTML5 and CSS. However, I have noticed that Caspio forms do not play too nicely with modal windows. I had to do some hacky things to get them to work.  If you would like more information, I will be happy help.

Link to comment
Share on other sites

  • 0
On 3/8/2018 at 10:55 AM, alineer said:

Do you want a modal or a popup? You can easily make a modal menu with HTML5 and CSS. However, I have noticed that Caspio forms do not play too nicely with modal windows. I had to do some hacky things to get them to work.  If you would like more information, I will be happy help.

Hi there,  I have been trying to get modals to work and you are correct the forms do not play nicely.  If you have a solution I would appreciate it.  thank you.

Link to comment
Share on other sites

  • 0

Hello, 

To create the modal pop-up window on my DataPage, I utilize their 'Generator'. JS seems to be not needed in this case. Here is the link of their generator.

It can also load the URL on the same page or another page.  It's a very big help because it generates the  HTML code for you.

Link to comment
Share on other sites

  • 0

Hi! Just an update - if you have a modal that is showing behind the Results Page, you can use this code in the Header:

<style>

.modal {
 z-index: 9999 !important;
}

</style>

In addition, if you would like to automatically adjust the size of the modal based on its content. You can use this code in the Header as well:

<style>

body .modal-dialog { /* Width */
max-width: 50%;
width: auto !important;
}

</style>

 

Link to comment
Share on other sites

  • 0
On 11/25/2022 at 2:27 PM, Meekeee said:

Hi! Just an update - if you have a modal that is showing behind the Results Page, you can use this code in the Header:

<style>

.modal {
 z-index: 9999 !important;
}

</style>

In addition, if you would like to automatically adjust the size of the modal based on its content. You can use this code in the Header as well:

<style>

body .modal-dialog { /* Width */
max-width: 50%;
width: auto !important;
}

</style>

 

In addition to this issue, there is another potential issue that you may encounter when having a modal in results page, where some of the fields in your form (i.e. bulk update) will be disabled. Here is a solution for that.

 

Link to comment
Share on other sites

  • 0

Hello - In addition to the previous post, if you have a modal and Form Elements that are not showing such as AutoComplete, Dropdowns, and Date Pickers, you can use a custom CSS to show these elements in front of the modal.

Insert this code in the Header of the DataPage.

<style>

.modal-backdrop{
z-index:4 !important;
}
.modal {
z-index: 5 !important;
}
.header-navbar{
z-index: 3 !important;
}

</style> 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...