Strange behavior with IE when writing a script that writes another script

B

Benoit Fries

Hello,

I have some problems with a Javascript that should redirect me to
another page, it works fine most of the times but sometimes it hangs
on a blank page.

I made lots of tests and finally I could reproduce the bug with this
little piece of code:

<script>
document.writeln("<scr"+"ipt>location='http://www.microsoft.com/';</scr"+"ipt>");
</script>

(I know it is unusual (and unnecessary) to write a script that writes
another script, but it's returned that way by a server I don't
control).

This script works. But if you use the back button more than 12 times,
then it won't work anymore. You 'll get a blank page.

Is this a feature or a bug? Do you know how to avoid that?

Thanks in advance,
Benoit Fries
 
T

Thomas 'PointedEars' Lahn

Benoit said:
I have some problems with a Javascript that should redirect me to
another page,

That's a Bad Thing, see below.
it works fine most of the times but sometimes it hangs on a blank page.

I made lots of tests and finally I could reproduce the bug with this
little piece of code:

<script>

The `type' attribute is missing.
document.writeln("<scr"+"ipt>location='http://www.microsoft.com/';</scr"+"ipt>");

No concatenation is required here but the
ETAGO delimiter `</' should be escaped: `<\/'.
</script>

(I know it is unusual (and unnecessary) to write a script that writes
another script, but it's returned that way by a server I don't
control).

More, it is not recommended because of the Netscape Run Length
Bug (NRLB). Try that in Netscape 4.x and you get broken code
sometimes.
This script works.
Depends.

But if you use the back button more than 12 times,
then it won't work anymore. You 'll get a blank page.

Is this a feature or a bug?

I do not know since you do not explain why you hit the `Back' button
this much and from which document(s) you are navigating to which.
Do you know how to avoid that?

Use server-side redirection, this also does not break the `Back' button.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top