0
这使我疯狂。我是一个复制/粘贴的人(!),所以请温柔。无法集中弹出工作
以前,我用this solution(Stack link)来做一个完美的工作(在内部CMS网站上)的中心弹出,但由于某种原因,我不能让它在一个新的网站上工作(不CMS)。
我知道我错过了一些东西,但我只是看不到它是什么!
HTML:
<a class="twitter" href="https://twitter.com" onclick="PopupCenter(this.href,'myWindow','550','550');return false" target="_blank">Center Popup</a>
的Javascript:
function PopupCenter(url, title, w, h) {
// Fixes dual-screen position Most browsers Firefox
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
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();
}
}
咦!?是吗!!?任何想法为什么它不适合我呢?这是我在
节得到了链接: – Kungfauxn00b没有这和你的函数PopupCenter(url,title,w,h)无关 –
你应该有一个像popup.html这样的html文件和一个JS文件作为popup .js包含您的功能 然后在您的popup.html中告诉您的HTML在哪里可以找到您的功能 –