UPDATE:window.open集中在形式提交(關)
答案可以在這裏找到:
center window.open on form submit
=========== ===========================================
我在嘗試將表單提交到以屏幕爲中心的彈出窗口中。我有「frankensteined」幾個js snippets,我發現谷歌搜索時。
請記住,我可以理解HTML/CSS,但不是JavaScript。
<html>
<head>
<script type="text/javascript">
function directions(sacred) {
var x = screen.width/2 - 700/2;
var y = screen.height/2 - 450/2;
window.open(sacred.action, 'Directions', 'height=485,width=700,left=' + x + ',top=' + y);
}
</script>
</head>
<body>
<form action="http://maps.google.com/maps" method="get" target="Directions"
onsubmit="Directions=directions(sacred)">
<p>
<input class="directions-input" id="saddr" name="saddr" type="text" placeholder="enter zip-code"
value="enter zip-code" onfocus="this.value = this.value=='enter zip-code'?'':this.value;"
onblur="this.value = this.value==''?'enter zip-code':this.value;" />
<input type="submit" class="directions-submit" />
<input type="hidden" name="daddr" value="210+East+Northampton+Street,+Bath,+PA"
/>
<input type="hidden" name="hl" value="en" />
</p>
</form>
</body>
</html>
的形式提交到一個新的標籤,並沒有運行功能或window.open
由於任何人提前。
P.S.我只是得到這個stackoverflow的東西。
什麼不正確?你還沒有問過問題。 – Madbreaks
@Madbreaks是的,我忘了那一部分。表單提交給新選項卡,並且不運行函數或window.open。 – jamesJosephFinn