问题
Hi Javascript gurus, I have this Javascript code which is working fine on Firefox , but it is not working on IE 7. Any ideas why?
Here is the code
function TestWindow()
{
SimpleWindow('Default.aspx', 'Simple Test', 200, 200, 'yes')
}
function SimpleWindow(mypage,myname,w,h,scroll)
{
var win= null;
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=no,location=no,status=no,menubar=no,resizable=no,dependent=no'
win=window.open(mypage,myname,settings)
if(parseInt(navigator.appVersion) >= 4)
{
win.window.focus();
}
}
回答1:
You may have realized that IE is giving the error "Invalid argument."
IE doesn't seem to like window names with spaces in them. Change 'Simple Test' to 'SimpleTest' etc.
回答2:
For myname parameter use only a-zA-Z0-9 characters. IE doesn't like any other, especially whitespace characters.
回答3:
Check popup blockers
回答4:
Check for reserved words. Your parameter name "scroll" is probably messing up your code in IE.
来源:https://stackoverflow.com/questions/1100320/popup-window-not-opening-on-ie7