ie8 var w = window.open() - " Message:Invalid argument。 [英] ie8 var w= window.open() - "Message: Invalid argument."

查看:235
本文介绍了ie8 var w = window.open() - " Message:Invalid argument。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站只有IE8问题:

I have a site that has an IE8-only problem:

代码为:

var w = window.open(urlstring, wname, wfeatures, 'false');

错误是:


消息:参数无效。

行:419
字符:5

代码:0

URI: http://HOSTNAME/js_context.js

我已经确认代码的行号(行和URI是正确的),我理解在IE8的更高版本中,这被认为是准确的。

I have confirmed the line number of the code (the "Line" and "URI" are correct), and I understand in later versions of IE8, this is considered accurate.

我通过转储警报检查了调用中的所有传入参数,它们看起来都是有效的。

I have checked all the incoming parameters in the call by dumping alerts, and they all look valid.

这个问题不会发生在FF上(可能是3个) 。

This problem does not happen on FF (probably 3).

更新:

问题似乎在于使用window.open()分配结果时做var w。当我将该行分成两个语句时,它在IE8中有效。

The problem appears to be in using assigning the result of window.open() when doing "var w". When I split the line into two statements it works in IE8.

UPDATE2:

基于:

http://javascript.crockford.com/code。 html


当一个函数立即被调用
时,整个调用
表达式应该是包含在parens
中,因此很明显产生的
值是
函数的结果,而不是函数本身。

When a function is to be invoked immediately, the entire invocation expression should be wrapped in parens so that it is clear that the value being produced is the result of the function and not the function itself.

这不完全是这里发生的事情,但我发现在IE8的兼容模式下应用该原则解决了这个问题。

This is not exactly what is going on here, but I found that applying the principle solved the problem, in IE8's compatability mode.

var w = (window.open(urlstring, wname, wfeatures, false));


推荐答案

这是一个旧帖子,但对某人可能仍然有用。

This is an old posting but maybe still useful for someone.

我有同样的错误信息。最后问题是第二个参数的名称无效,即我有一行如下:

I had the same error message. In the end the problem was an invalid name for the second argument, i.e., I had a line like:

   window.open('/somefile.html', 'a window title', 'width=300');

问题是'窗口标题',因为它无效。它在以下行中运行良好:

The problem was 'a window title' as it is not valid. It worked fine with the following line:

   window.open('/somefile.html', '', 'width=300');

事实上,仔细阅读我发现微软不支持名称作为第二个参数。当你查看官方文档页面,你看到微软只允许以下参数,如果使用那个参数:

In fact, reading carefully I realized that Microsoft does not support a name as second argument. When you look at the official documentation page, you see that Microsoft only allows the following arguments, If using that argument at all:


  • _blank

  • _media

  • _parent

  • _search

  • _self

  • _top

  • _blank
  • _media
  • _parent
  • _search
  • _self
  • _top

这篇关于ie8 var w = window.open() - " Message:Invalid argument。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆