2012-11-13 44 views
0

說實話,我根本不懂JavaScript。我一直在通過觀察別人來弄清楚事情,但這次不是這樣!我希望我的一個表單能夠以提交爲中心彈出。我已經得到它彈出並保留表格數據到目前爲止,但我似乎不能讓它居中!這裏是一些與我一起工作的代碼:Popup form centered

此外,如果有人可以向我解釋這將是偉大的。我的表單動作看起來有點像document.getElementByID('Name').vaule加上電子郵件等瘋狂,但表單字段ID與動作不匹配,但它仍然工作。我不知道這一個或爲什麼它的實際工作仍http://www.computerbytez.com/develop.html在行動的形式

方式:!

<form action="https://computerbytez.com/InstantChat/Standard/logmein.html?Name=' + document.getElementById('Name').value + '&amp;Email=' + document.getElementById('Name').value, '', 'toolbar=no, status=no, menubar=no, titlebar=no, location=no, scrollbars=no, resizable=no, height=500, width=400'" id="lmiform"> 
      <div class="form-field"> 
     <label class="cm-required " for="elm_7">Name</label> <input class="input-text" id="elm_7" name="name" size="50" style="width: 100%; max-width: 372px;" type="text"/></div> 
<div class="buttons-container"> 
     <span class="button-submit button-wrap-left"><span class="button-submit button-wrap-right"><input type="submit" value="Connect To Technician" /></span></span></div> 

形式的JavaScript:

$(document).ready(function() { 
    $('#lmiform').submit(function() { 
window.open('', 'formpopup', 'width=620,height=480,scrollbars=no,resizable=no,top=200,left=200'); 
     this.target = 'formpopup'; 
    }); 
}); 

我也一直在搞亂這個(彈出中心的鏈接)和我一直在試圖將兩者結合在一起,沒有運氣:

<script> 
function PopupCenter(pageURL, title,w,h) { 
var left = (screen.width/2)-(w/2); 
var top = (screen.height/2)-(h/2); 
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left); 
} 
</script> 

<a href="javascript:void(0);" onclick="PopupCenter('example.html', 'myPop1',620,470);"><img alt="" class="LMIpic" src="live_help_online.gif" /> </a> 

任何幫助將不勝感激。謝謝

+0

'javascript'無關用'java'。請勿誤用標籤。 – gdoron

回答

4

我已訪問過您的網站,並且點擊圖片時彈出窗口顯示居中且罰款。代碼看起來很不錯。嘗試清除瀏覽器緩存。

編輯:

$(document).ready(function() { 
     $('#lmiform').submit(function() { 
      var left = (screen.width/2)-(620/2); 
      var top = (screen.height/2)-(480/2); 
      window.open('', 'formpopup', 'width=620,height=480,scrollbars=no,resizable=no,top='+top+',left='+left); 
      this.target = 'formpopup'; 
     }); 
    }); 
+0

已經有!它不是一個圖像,它的按鈕說「連接技術人員」,它現在從頂部和左側打開200px。 – user1819416

+0

你的問題不是很清楚。如果您希望提交彈出窗口居中,請嘗試上述回答中的編輯。 – 5hahiL

+0

順便說一句,我正在談論的PopupCenter()函數設置的live_help_online.gif圖像。彈出窗口以您的功能正確居中。 – 5hahiL