Flash调用window.location.hash会导致IE6崩溃 [英] Flash calling window.location.hash causes IE6 crash

查看:52
本文介绍了Flash调用window.location.hash会导致IE6崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个HTML javascript应用程序,我希望以可以书签的方式保留

状态。我选择HTML锚点作为保存状态的手段

。当应用程序更改状态时,HTML页面

URL将从default.html更改为default.html#stateA。


示例: http://pearstudios.com/javascript/lo...hAndFlash.html


这在HTML和javascript中完全有效,但是,当连接Flash和javascript时,这是一个难点。

每个我用Flash调用的其他javascript函数

getURL(" javascript :x");完美无缺,但是当window.location.hash

=" x" ;, window.location.href =" baseUrl.html#" +" x";或

window.location.assign(" baseUrl.html#" +" x");从Flash调用,IE

6.0崩溃(或用空白页替换当前页面)。奇怪的是,

崩溃发生在Flash第二次调用javascript函数时。


有没有人知道为什么会这样,我怎么能得到

围绕这个问题?


谢谢,

马克

I am developing an HTML javascript application and I want to preserve
state in a way that can be book-marked. I chose HTML anchors as a means
of preserving state. When the application changes state, the HTML page
URL would change from default.html to default.html#stateA.

example: http://pearstudios.com/javascript/lo...hAndFlash.html

This has worked perfectly within HTML and javascript alone, however,
when connecting Flash and javascript, this is the one sticking point.
Every other javascript function that I have called from Flash using
getURL("javascript: x"); works perfectly, but when window.location.hash
= "x";, window.location.href = "baseUrl.html#" + "x";, or
window.location.assign("baseUrl.html#" + "x"); is called from Flash, IE
6.0 crashes (or replaces the current page with a blank page). Oddly,
the crash occurs the second time Flash calls the javascript function.

Does anyone have any idea why this is happening and how I can get
around this problem?

Thanks,
Mark

推荐答案

Simula写道:
我正在开发一个HTML javascript应用程序,我希望
以一种可以书签的方式保存状态。我选择HTML锚点作为保存状态的手段。当应用程序更改状态时,HTML页面URL将从default.html更改为default.html#stateA。

示例: http://pearstudios.com/javascript/lo...hAndFlash.html

这在HTML和javascript中完全有效,但是,当连接Flash和javascript时,


看来flash执行javascript的唯一机制是

(而不是它自己的ECMAScript实现)是使用

javascript伪协议和getURL函数。


使用javascript强烈建议不要使用伪协议,因为它不会被用来替换页面内容,因为它在包括Windows IE 6在内的众多网络浏览器中都会产生有害的后果。很多网站

开发人员继续使用javascript伪协议hrefs并保持

不知道有害后果,因为他们从未见过他们。

但是,这个小组的档案提供了许多这些后果的例子。


javascript伪协议是一种机制,用于通过评估javascript

表达式产生的字符串替换页面的

内容。当使用的表达式求值为未定义的值(因为大多数函数调用将是b / b
)时,浏览器不会替换当前页面的内容。但是,使用javascript伪协议

仍然看起来像浏览器一样导航。因此,一些浏览器

将当前页面置于等待状态,等待预期的

替换。


在这种状态下,浏览器停止执行一些资源匮乏的任务,例如动画GIF图像的动画,以及onmouseover上的图像交换。这些是使用javascript伪协议后页面状态改变最明显的表现形式

,其他不太明显的结果

后果状态改变意味着一旦使用了javascript伪
协议,所有的赌注都将关闭浏览器

环境下一步的表现。


你觉得能够描述浏览器的行为

跟随javascript伪协议使用''完美地工作''建议

非常好运或者非常肤浅的测试。

这是一个难点。我使用
getURL(" javascript :x")从Flash调用的所有其他javascript
函数;
window.location.hash =" x";
window.location.href =" baseUrl.html#" +" x";,


这些表达式不是函数调用。如果这些表达式是javascript伪协议表达式中的
,而不是

- void - 运算符的操作数,那么它们的使用可能会很危险,因为表达式

导致值并将当前文档的标记替换为

这样的表达式结果不太可能产生理想的结果。

或窗口。 location.assign(" baseUrl.html#" +" x");
从Flash调用,IE 6.0崩溃(或用空白页替换当前页面)。
奇怪的是,崩溃发生在Flash第二次调用javascript函数时。


如果仅在第二次使用javascript伪

协议时观察到效果,则很可能是状态的结果

由初次使用引起的页面发生变化。

有没有人知道为什么会发生这种情况以及如何解决这个问题?
I am developing an HTML javascript application and I want
to preserve state in a way that can be book-marked. I
chose HTML anchors as a means of preserving state. When
the application changes state, the HTML page URL would
change from default.html to default.html#stateA.

example: http://pearstudios.com/javascript/lo...hAndFlash.html

This has worked perfectly within HTML and javascript
alone, however, when connecting Flash and javascript,
It appears that the only mechanism flash offers for executing javascript
(as opposed to its own ECMAScript implementation) is the use of the
javascript pseudo protocol and the getURL function.

The use of the javascript pseudo protocol is strongly discouraged where
it is not being used to replace page content because it is has harmful
consequences in numerous web browsers including Windows IE 6. Many web
developers carry on using javascript pseudo protocol hrefs and remain
unaware of the harmful consequences because they never see them.
However, the archives for this group provide many examples of those
consequences.

The javascript pseudo protocol is a mechanism for replacing a page''s
contents with a string that results from the evaluation of a javascript
expression. When the expression used evaluates to an undefined value (as
most function calls would) the browser does not replace the contents of
the current page. However, the use of the javascript pseudo protocol
still looks to the browser like navigation. As a result some browsers
put the current page into a ''waiting'' state, pending its expected
replacement.

In this state browsers stop doing some resource hungry tasks, such as
animating animated GIF images, and image swapping onmouseover. These are
the most visible manifestations of the altered state of the page
following the use of the javascript pseudo protocol, other less visible
consequences of the state change mean that once a javascript pseudo
protocol has been used all bets are off as to how the browser
environment will behave next.

That you feel able to characterise the behaviour of the browser
following javascript pseudo protocol use as ''worked perfectly'' suggests
very good fortune or very superficial testing.
this is the one sticking point. Every other javascript
function that I have called from Flash using
getURL("javascript: x"); works perfectly, but when
window.location.hash = "x";,
window.location.href = "baseUrl.html#" + "x";,
These are expressions not function calls. If these expressions are
within the javascript pseudo protocol expression, and not the operand of
the - void - operator, their use might be dangerous, as expressions
result in values and replacing the mark-up of current document with the
result of such an expression is unlikely to produce a desirable outcome.
or window.location.assign("baseUrl.html#" + "x");
is called from Flash, IE 6.0 crashes (or replaces
the current page with a blank page). Oddly, the crash occurs the second time Flash calls
the javascript function.
If the effect is only observed on the second use of a javascript pseudo
protocol then it is very likely to be the consequence of the state
change in the page provoked by the initial use.
Does anyone have any idea why this is happening and how
I can get around this problem?




你应该完全放弃使用javascript伪协议,

但是当你调用javascript的唯一方法是
$ b时你不能这样做$ b Flash的getURL方法。因此,您唯一的选择是重新考虑状态

保存机制,或放弃使用Flash作为

应用程序的一部分。


Richard。



You should totally abandon the use of the javascript pseudo protocol,
but you cannot do so when your only means of calling javascript is
Flash''s getURL method. So your only options are to re-think the state
preservation mechanism, or abandon using Flash as part of the
application.

Richard.




Richard Cornford写道:

Richard Cornford wrote:
Simula写道:
我正在开发一个HTML javascript应用程序,我希望
以一种可以书签的方式保存状态。我选择HTML锚点作为保存状态的手段。当应用程序更改状态时,HTML页面URL将从default.html更改为default.html#stateA。

示例: http://pearstudios.com/javascript/lo...hAndFlash.html

这在HTML和javascript中完全有效,但是,当连接Flash和javascript时,
I am developing an HTML javascript application and I want
to preserve state in a way that can be book-marked. I
chose HTML anchors as a means of preserving state. When
the application changes state, the HTML page URL would
change from default.html to default.html#stateA.

example: http://pearstudios.com/javascript/lo...hAndFlash.html

This has worked perfectly within HTML and javascript
alone, however, when connecting Flash and javascript,



这似乎是flash执行javascript的唯一机制
(而不是它自己的ECMAScript实现)是使用
javascript伪协议和getURL函数。

强烈建议不要使用javascript伪协议。
它是不被用来替换页面内容,因为它在包括Windows IE 6在内的众多Web浏览器中都会产生有害后果。许多Web开发人员继续使用javascript伪协议hrefs并且仍然没有意识到有害C因为他们从来没有见过他们的后果。
然而,这个小组的档案提供了很多这些后果的例子。

javascript伪协议是一种替换页面的机制'' s
带有字符串的内容,该字符串来自对javascript
表达式的评估。当使用的表达式求值为未定义的值时(如大多数函数调用那样),浏览器不会替换当前页面的内容。但是,javascript伪协议的使用仍然像导航一样向浏览器看。因此,一些浏览器将当前页面置于等待状态,等待其预期的替换。

在这种状态下,浏览器停止执行一些资源匮乏的任务,例如动画制作动画GIF图像和图像交换onmouseover。这些是页面状态改变后最明显的表现
使用javascript伪协议之后,其他不太明显的状态变化后果意味着一旦javascript伪
协议已被使用关于浏览器
环境将如何表现的所有下注。

您觉得能够描述浏览器的行为
以下javascript伪协议使用''完美地工作''建议
非常好运或非常肤浅的测试。



It appears that the only mechanism flash offers for executing javascript
(as opposed to its own ECMAScript implementation) is the use of the
javascript pseudo protocol and the getURL function.

The use of the javascript pseudo protocol is strongly discouraged where
it is not being used to replace page content because it is has harmful
consequences in numerous web browsers including Windows IE 6. Many web
developers carry on using javascript pseudo protocol hrefs and remain
unaware of the harmful consequences because they never see them.
However, the archives for this group provide many examples of those
consequences.

The javascript pseudo protocol is a mechanism for replacing a page''s
contents with a string that results from the evaluation of a javascript
expression. When the expression used evaluates to an undefined value (as
most function calls would) the browser does not replace the contents of
the current page. However, the use of the javascript pseudo protocol
still looks to the browser like navigation. As a result some browsers
put the current page into a ''waiting'' state, pending its expected
replacement.

In this state browsers stop doing some resource hungry tasks, such as
animating animated GIF images, and image swapping onmouseover. These are
the most visible manifestations of the altered state of the page
following the use of the javascript pseudo protocol, other less visible
consequences of the state change mean that once a javascript pseudo
protocol has been used all bets are off as to how the browser
environment will behave next.

That you feel able to characterise the behaviour of the browser
following javascript pseudo protocol use as ''worked perfectly'' suggests
very good fortune or very superficial testing.

这是一个棘手的问题。我使用
getURL(" javascript :x")从Flash调用的所有其他javascript
函数;
window.location.hash =" x";
window.location.href =" baseUrl.html#" +" x";,
this is the one sticking point. Every other javascript
function that I have called from Flash using
getURL("javascript: x"); works perfectly, but when
window.location.hash = "x";,
window.location.href = "baseUrl.html#" + "x";,



这些是表达式而不是函数调用。如果这些表达式在javascript伪协议表达式中,而不是 - void - 运算符的操作数,则它们的使用可能是危险的,因为表达式会导致值并替换标记 - 具有这种表达结果的当前文档不太可能产生理想的结果。



These are expressions not function calls. If these expressions are
within the javascript pseudo protocol expression, and not the operand of
the - void - operator, their use might be dangerous, as expressions
result in values and replacing the mark-up of current document with the
result of such an expression is unlikely to produce a desirable outcome.

或window.location.assign(" baseUrl.html#" +" x");
从Flash调用,IE 6.0崩溃(或用空白页替换当前页面)。
or window.location.assign("baseUrl.html#" + "x");
is called from Flash, IE 6.0 crashes (or replaces
the current page with a blank page).


奇怪的是,崩溃发生在Flash第二次调用javascript函数时。
Oddly, the crash occurs the second time Flash calls
the javascript function.



如果仅在第二次使用javascript伪
协议时观察到效果然后它很可能是由初次使用引起的页面状态变化的结果。



If the effect is only observed on the second use of a javascript pseudo
protocol then it is very likely to be the consequence of the state
change in the page provoked by the initial use.

有没有人知道为什么会发生这种情况以及如何
我可以解决这个问题吗?
Does anyone have any idea why this is happening and how
I can get around this problem?



你应该完全放弃使用javascript伪协议,但当你调用javascript的唯一方法是 Flash的getURL方法。因此,您唯一的选择是重新考虑状态保存机制,或放弃使用Flash作为
应用程序的一部分。

理查德。



You should totally abandon the use of the javascript pseudo protocol,
but you cannot do so when your only means of calling javascript is
Flash''s getURL method. So your only options are to re-think the state
preservation mechanism, or abandon using Flash as part of the
application.

Richard.



理查德:

有趣,但抽象和无用:就像一个共鸣为什么所有人

应该是兄弟。 javascript :伪协议是上帝在页面脚本和Flash / Java之间进行
通信的礼物;因为

*官方*通信方式只适用于纸张和损坏的头脑

写这些文件的人。


要OP:

使javascript :调用可靠,*总是*使用void()包装。


在你的Flash中(在旧的ActiveScript上,我没有学习的新版本):

....

设置jsCommand =" setCookie(&& cookieValue&" )" ;;

设置jsCode =" javascript :void(&& jsCommand&")" ;;

getURL (jsCode);

....


PS如果你想保持任何类型的*州*,饼干应该是

永远是第一选择。


P.P.S.即使没有任何

脚本,IE传统上也存在很大问题。当您在同一个

页面上从一个锚点导航到另一个锚点时,版本3,4和5(在不同的次要版本中)倾向于

crach。


To Richard:
Interesting, but abstract and useless: like a resonning "Why all people
should be brothers". javascript: pseudo-protocol is a God''s gift for
communication between the page script and Flash/Java; because the
*official* communucation ways work only on paper and in damaged minds
of people who wrote these papers.

To OP:
to make javascript: call reliable, *ALWAYS* use void() wrapper.

In your Flash (on the old ActiveScript, the new one I did not learn):
....
Set jsCommand = "setCookie(" & cookieValue & ")";
Set jsCode = "javascript:void(" & jsCommand & ")";
getURL(jsCode);
....

P.S. If you want to keep a *state* of any kind, cookies should be
always the first choice.

P.P.S. IE traditionally has big problems with anchors even w/o any
script. Versions 3, 4 and 5 (in different minor releases) tended to
crach when you simply navigated from one anchot to another on the same
page.


我非常感谢Richard的帮助。我尝试了各种各样的事情来支持
从Flash调用中解析location.hash(甚至更改由本机javascript代码轮询的全局

变量)。我无法确定IE6的行为,但是你对''等待状态'的解释'

会让一切变得清晰。


还有另一种尝试Flash进行javascript通信的方法

- Flash FS命令。你知道FS命令是否会导致任何类似的

浏览器问题吗?


非常感谢您的详细解释,

Mark

I really appreciate the help Richard. I tried all sorts of things to
de-couple the location.hash from the Flash call (even changing global
variables that were polled by native javascript code). I couldn''t make
sense of IE6''s behavior, but your explanation of the ''waiting state''
makes everything clear.

There is another method of attempting Flash to javascript communication
- Flash FS commands. Do you know if FS commands cause any similar
browser problems?

Thank you so much for the detailed explanation,
Mark


这篇关于Flash调用window.location.hash会导致IE6崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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