admin管理员组

文章数量:1418687

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();
        }
    }

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();
        }
    }
Share Improve this question edited Jul 8, 2009 at 20:25 Ateş Göral 140k27 gold badges141 silver badges191 bronze badges asked Jul 8, 2009 at 20:17 ShivaShiva 1,4092 gold badges16 silver badges32 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

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.

For myname parameter use only a-zA-Z0-9 characters. IE doesn't like any other, especially whitespace characters.

Check popup blockers

Check for reserved words. Your parameter name "scroll" is probably messing up your code in IE.

本文标签: javascriptPopup window not opening on IE7Stack Overflow