我找到了一个将弹出窗口置于屏幕中心的功能:
function PopupCenter(url, title, w, h) {
// Fixes dual-screen position Most browsers Firefox
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : window.screenX;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : window.screenY;
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var left = ((width / 2) - (w / 2)) + dualScreenLeft;
var top = ((height / 2) - (h / 2)) + dualScreenTop;
var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
// Puts focus on the newWindow
if (window.focus) {
newWindow.focus();
}
}
但是当我试图通过按下图像来调用它时,没有任何反应,我甚至没有得到一个“klick me”鼠标。
<img src="https://rainbowcats.se/img/btn-makeown.gif" height ="auto" width ="80%"alt="Skapa din egen minnessida" onclick= "PopupCenter('https://upload.rainbowcats.se','xtf','900','500');">
该功能在头部加载,另一部分在体内..
有人有任何建议吗?
答案 0 :(得分:0)
我为自己感到羞耻。
我忘记了最重要的事情,我忘了在JavaScript中设置函数
<script type="text/javascript">
(Function)
</Script>
有时这是最简单的事情,让人头脑清醒......