473,581 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Flash calling window.location .hash causes IE6 crash

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#st ateA.

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("javascr ipt: x"); works perfectly, but when window.location .hash
= "x";, window.location .href = "baseUrl.ht ml#" + "x";, or
window.location .assign("baseUr l.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

Aug 7 '05 #1
18 12661
Simula wrote:
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#st ateA.

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("javascr ipt: x"); works perfectly, but when
window.location .hash = "x";,
window.location .href = "baseUrl.ht ml#" + "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("baseUr l.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?


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.
Aug 7 '05 #2
VK

Richard Cornford wrote:
Simula wrote:
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#st ateA.

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("javascr ipt: x"); works perfectly, but when
window.location .hash = "x";,
window.location .href = "baseUrl.ht ml#" + "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("baseUr l.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?


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.

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:voi d(" & 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.

Aug 7 '05 #3
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

Aug 7 '05 #4
VK wrote:
Richard Cornford wrote: <snip>
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. <snip>
Oddly, the crash occurs the second time Flash calls
the javascript function.

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.
Navigating to a javascript pseudo-protocol href that does not result in
the replacement of the current page is an act akin to kicking the
browser really hard. How well it will function after that act is
anyone's guess, beyond being certain that particular browsers will stop
performing particular actions.

You might think that kicking browsers is acceptable because you have
never been able to recognise the consequences as related to the action,
but that doesn't make it so. Indeed the fact that you perceive browser
scripting as buggy and chaotic well beyond what anyone else experiences
is likely, at least in part, the result of kicking browsers into states
in which they were not expecting to be scripted.
To OP:
to make javascript: call reliable, *ALWAYS* use
void() wrapper.
void - is an operator and should not be presented in a way that may give
the mistaken impression that it is a function.

If the expression evaluated in a javascript pseudo protocol href is a
function call that returns the Undefined value (as they all do if they
are not explicitly asked to return something else) then using that value
as the operand for the - void - operator will make no difference to the
outcome at all.

I realise that analysing cause and effect from observed behaviour is a
skill you don't posses, but the factor that needs explaining here is why
the effect is only observed on the _second_ use of the javascript
pseudo-protocol. In all circumstances where applying the - void -
operator to the evaluated result of an expression within a javascript
pseudo protocol href would make any difference to the outcome the effect
would be observed on each and every use of the href, including the
first.

<snip> P.S. If you want to keep a *state* of any kind, cookies
should be always the first choice.
For you that may be the case, for everybody else persistent cookies
would be the last choice of mechanism for maintaining state.
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.


I don't know about IE 3 (and don't care much at this point) but for IE 4
& 5 that is pure BS. Once again, with your catastrophicall y bad
scripting you may encounter this effect, but when your are encountering
problems that nobody else experiences it makes more sense to look at
what your are doing wrong rather than blaming the browser when it
suffers from it.

Richard.
Aug 7 '05 #5
Simula wrote:
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?


Ah, yes, I remember FS commands. I have never used them, but then it has
been more than 3 years since I have had anything to do with Flash, as I
do cross-browser work. As I understand it the potential problem with
them are that they require the browser to fully and correctly implement
a standardised interface for plug-ins, and the browsers just don't. At
least not all of them, which may or may not be a problem depending on
how controllable/restricted the target browsers for your application are
(and what those actual browser do).

Richard.
Aug 7 '05 #6
VK
Richard Cornford wrote:
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.

void() was specially introduced both in NN3 and IE3 when the need in
script-launching links got really bad.
Don't forget (if you had a chance ever learn it of course) that at that
time there was not any Event object you could capture, cancelBubble
etc.

So the scripters had to use the "empty anchor" trick:
<a href="#" onClick="myFunc tion()">Click here</a>

Unfortunatelly in IE3 the empty anchor was set as a synonym of the top
of the document. So clicking such pseudo-link caused the scroll on the
very top. Obviously for large documents it was not acceptable.

Then one tried the evident trick with "self-pointing anchor":
<a name="bogus" href="#bogus" onClick="myFunc tion()">Click here</a>
The results appeared to be disactrous on both rivals.

Both producers saw the problem and rushed to intriduce
javascript:void (0) construct, which solved the problem:
<a href="javascrip t:void(0)" onClick="myFunc tion()">Click here</a>

Thusly void() (actually void(0) ) was made exclusively for javascript
pseudo-protocol and overall it doesn't have any other reasonnable use.
So *javascript:voi d(anything)* is totally correct and
producer-predicted construction. It has no more chance to "kick off"
the browser than <body> or <html> tags.

It is a totally other story that since 4th versions users have other
means to create and handle pseudo-links.

<snip a lot of foo>
I don't know about IE 3 (and don't care much at this point) but for IE 4
& 5 that is pure BS.


I publich here the minor versions/OS of IE with the "anchor
instability" (skipping IE3), and you post in this group a message with
the string "Intenet Explorer is the best browser!" repeated 10 times.
If I fail, my post will repeat "I am an ignorant fool" 10 times. We
shall make it "no cache" of course.
???
Interestingly enough the "anchor instability" was always acted starting
the second and more navigation within the same page, but never on the
first one.

Aug 7 '05 #7


Simula wrote:

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("javascr ipt: x"); works perfectly, but when window.location .hash
= "x";, window.location .href = "baseUrl.ht ml#" + "x";, or
window.location .assign("baseUr l.html#" + "x"); is called from Flash, IE
6.0 crashes (or replaces the current page with a blank page).


But if you use getURL why do you need to couple it with script and
window.location .hash?
Doesn't it suffice if you simply call
getURL('#anchor Name')
in Flash?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 7 '05 #8
VK

Simula wrote:
There is another method of attempting Flash to javascript communication
- Flash FS commands.


FS is broken (and always was). Don't waste your time on it. You you
may... for sport...

javascript:void (jsFunction) works stable and on all browsers.

Aug 7 '05 #9
VK wrote:
Richard Cornford wrote:
>> 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.
void() was specially introduced both in NN3 and IE3 when the
need in script-launching links got really bad.
Do you have any evidence that this was the motivation behind the
introduction of the void operator in JavaScript 1.1, or are you making
this up off the top of your head again?
Don't forget (if you had a chance ever learn it of course)
that at that time there was not any Event object you
could capture, cancelBubble etc.
Not having an event object is not a barrier to cancelling most intrinsic
events in JavaScritp 1.1+.
So the scripters had to use the "empty anchor" trick:
<a href="#" onClick="myFunc tion()">Click here</a>
But people who understood what they were doing had the option of
cancelling the navigation in the onclick event from JavaScript 1.1
onwards, so manifestations of the common practice of writing scripts
without understanding what you are doing have no significance.
Unfortunatelly in IE3 the empty anchor was set as a
synonym of the top of the document.
The # character as a URI is an empty URI followed by an empty fragment
identifier. RFC 2396, section 4.2, defines that as a reference to the
"start of the document". The only decision on the subject that the
browser manufactures have made is to equate the "start" of a document
with the top of a displayed page. Not an unreasonable interpretation at
all.
So clicking such pseudo-link caused the scroll on the
very top.
It is not a pseudo-link, it is a link with a well formed URI that refers
to the "start of the document". Navigating to the top of the page is the
navigation such a URI is requesting.
Obviously for large documents it was not acceptable.
If you want to go to the top of the current page that is completely
acceptable.
Then one tried the evident trick with "self-pointing
anchor":
<a name="bogus" href="#bogus" onClick="myFunc tion()">
Click here</a>
The results appeared to be disactrous on both rivals.

Both producers saw the problem and rushed to intriduce
javascript:void (0) construct, which solved the problem:
<a href="javascrip t:void(0)" onClick="myFunc tion()">
Click here</a>
They introduced the - void - operator at exactly the point that they
made intrinsic events cancellable, so there is no reason to believe that
the introduction of - void - was in any way related.
Thusly void() (actually void(0) ) was made exclusively
for javascript pseudo-protocol and overall it doesn't
have any other reasonnable use.
Which would explain why you don't find any - void - operators in any
languages that cannot be executed in pseudo-protocol hrefs?
So *javascript:voi d(anything)* is totally correct and
producer-predicted construction. It has no more chance
to "kick off" the browser than <body> or <html> tags.
Reality is not altered by your unwillingness to recognise it.
It is a totally other story that since 4th versions users
have other means to create and handle pseudo-links.

<snip a lot of foo>
That is right; never wonder why people disagree with you, just ignore
whatever they have to say.
I don't know about IE 3 (and don't care much at this
point) but for IE 4 & 5 that is pure BS.


I publich here the minor versions/OS of IE with the "anchor
instability" (skipping IE3), and you post in this group a
message with the string "Intenet Explorer is the best
browser!" repeated 10 times. If I fail, my post will repeat
"I am an ignorant fool" 10 times. We shall make it "no
cache" of course. ???


Incoherent as ever.
Interestingly enough the "anchor instability" was always
acted starting the second and more navigation within the
same page, but never on the first one.


It remains no surprise to me that your particular style of scripting
provokes problems with web browsers that have apparently never been seen
by anyone else. But as you never seem to understand what you are doing
there is no point pursuing the real cause and effect relationships
involved with you.

Richard.
Aug 7 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
8572
by: Keith Rowe | last post by:
Hello, I am trying to reference a Shockwave Flash Object on a vb code behind page in an ASP.NET project and I receive the following error: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). On the aspx page I have the object tag as follows:
5
7515
by: spam_me_ not | last post by:
I already understand that one cannot disable a browser's forward and back functions. This is a situation where I have code working in Mozilla V1.6 and would like something similar for Opera and IE. I link within a page and display individual divisions of that page, manipulating their visibility and display styles with an onClick function....
3
3090
by: Stewart | last post by:
Dear javascripters, Through a frustrating afternoon of debugging I appear to have discovered something: Setting location.hash to an empty string in the global namespace (not inside a function) Mozilla/FireFox/Netscape causes the browser to go into an infinite loop, apparently attempting to reload the page. ie: <script...
2
8803
by: Dennis Ålund | last post by:
Is it possible to notice a change of window.location.hash without polling? I'm working on a Ajax-platform (yes, inventing the wheel again) and have finished almost everything except the support for back/forward-buttons. The track I'm working on is "hidden frames" to keep state in window.location.hash. I've seen some solutions along this...
4
13073
by: Jeff Paffett | last post by:
I'm writing a file manager application using Ajax techniques and the client wants to be able to bookmark file searches. I send the search request to a remote server using a XMLHttpRequest and then write the search string to a # URL, either using window.location.href or window.location.hash. This works fine with no problems in IE and Firefox...
3
1705
by: johnsonholding | last post by:
Here is the script I have in my page : <!-- Begin function popUp(URL) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=194,height=146,left = 440,top = 288');"); }
18
3319
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to the image. The desired behavior is that when the pop-up is invoked, I want the underlying window to stay put. I don't have this problem when I...
13
2513
by: ababeel | last post by:
Hi I am using a calloc in a hash table program on an openvms system. The calloc is used to declare the hash table char **pHashes; pHashes = calloc(hash_size,sizeof(char *)); //hash_size = 101 and then later on when it is half full i do the following char **newHashes; if(newHashes)
2
8060
dream party
by: dream party | last post by:
Inserting a Flash (SWF, FLV) file into HTML web page is already an old and familiar thing to all of us. It is a rather non-flexible thing that just to edit some options in the template. However, I did not understand some parameters totally in the HTML tag. These days when I was surfing the Internet I have found some comprehensive introduction to...
0
7868
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8304
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8175
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6553
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5674
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3827
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1403
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.