Tell me I’m going to make sure that on every page of the user there is a button, when clicked, a form is created in a modal window to send a message.

function createBlock(){ var block = document.createElement('div'); block.className = 'overlay' block.innerHTML = 'код' document.body.appendChild(block); } 

Here is the code that will create the element, etc. Tell me what to add in front of it so that the screen would be darkened before creating the form? Is it possible to create an element animated? + Do you have to write all the form code in block.innerHTML? Or can you paste the code from a third-party file there? Thanks in advance! )

  • 3
    And why such a binding to jQuery version 1.5.2? Is this fundamentally non-editable? - Deonis

1 answer 1

I have an old example . I just adapted it for version 1.5.2 and it seems to be working fine. There is something superfluous there, but I think you will find what you need. To load a modal window of an external document (or part of it), you can use or $ .ajax () , in particular, the .load () method will suit you, or you can use an iframe.

  • one
    Thank you! And how to make this modal window become centered on the page, centered? - OverLoader
  • If you know the final dimensions and ask them yourself, you can do it this way . If the dimensions are not known, then it is necessary to “manifest” the object, calculate its dimensions and also, as in the example above, substitute the values ​​in the formula. For a more accurate fit, it is necessary to take into account the errors (margin, padding, border, etc.) of the elements. - Deonis
  • one
    I just wrote a wall for the project, but there is a nuance in it that the older versions do not allow it to work correctly, that is, the AJAX does not display data, that is, the user's messages ... now I will think how to fix it, but it’s far from I understand you will not leave? - OverLoader
  • one
    Ps when I inserted a modal window into my project, it opens everything is fine, but when I click on the background, it is not hidden ( - OverLoader