Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="mainDIV">...</div>
- <script>
- modalWindow = null;
- wndTitle = ':: ';
- function showModalWindow(handle, title, w, h, html) {
- var win = document.createElement('div');
- var time = (new Date).getTime();
- win.style.position = 'absolute';
- win.style.width = w;
- win.style.height = h;
- win.style.backgroundColor = '#f5f5f5';
- win.style.border = '1px solid #a0a0a0';
- win.style.paddingTop = '2px';
- win.style.left = '300px';
- win.style.top = '300px';
- win.style.filter= 'alpha(opacity=20)';
- win.style.opacity='56';
- win.id = 'dmainWindow'+time;
- win.style.zIndex = time;
- win.onclick = function() {
- with(this) { style.zIndex = (new Date).getTime(); }
- }
- iHTML = '<div class="windowBar" onmousedown="return setDnD(event,this,\'dmainWindow'+time+'\');">';
- iHTML += ' '+wndTitle+' '+title;
- iHTML += '</div>';
- iHTML += '<div class="closeButton" onclick="this.parentNode.style.display = \'none\'; this.parentNode.style.visibility = \'hidden\'; this.parentNode.innerHTML = null; modalWindow = null;">';
- iHTML += 'X';
- iHTML += '</div><br />';
- iHTML += '<div style="padding: 5px;">'+html+'</div>';
- win.innerHTML = iHTML;
- //handle.parentNode.insertBefore(win,handle);
- //document.body.appendChild(win);
- document.getElementById('mainDIV').appendChild(win);
- /*
- var winBar = document.createElement('div');
- winBar.style.cursor = 'pointer';
- winBar.style.backgroundColor = '#b70000';
- winBar.style.color = '#ffffff';
- winBar.style.fontSize = '10px';
- winBar.style.fontFamily = 'tahoma';
- winBar.innerHTML = 'AQQ';
- win.parentNode.insertBefore(winBar,win);
- */
- modalWindow = win;
- var winForm = win.getElementsByTagName('form');
- winForm[0].onsubmit = function (){
- with(this) {
- var out = '-';
- for(var a=0; a<elements.length; a++) {
- //if (elements[a].type != 'submit') {
- out += "&"+elements[a].name+'='+elements[a].value;
- //}
- }
- }
- out = out.replace('-&', '');
- out = out.replace('-', '');
- win.style.display = 'none';
- win.style.visibility = 'hidden';
- win.innerHTML = null;
- modalWindow = null;
- //test = out;
- // if (handle) {
- handle.innerHTML = out;
- handle.value = out;
- return out;
- // } else {
- //return "b";
- //}
- }
- }
- window.onload = function () {
- var htmlCode = '<form><input type=submit name=hm value=tak /> <input type=submit value=nie /></form>';
- var test = showModalWindow(this, 'test2', 230, 100, htmlCode);
- }
- </script>
- <div id="mainDIV">
- ugh
- </div>
- <a href="javascript:void(0);" onclick="alert(test);">TEST</a>
Add Comment
Please, Sign In to add comment