最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Popup window not opening on IE7 - Stack Overflow

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论