473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Why document.write creates a new entry in browser history (how to avoid it)?

On the current page the user is at I need to write something like
"Please, wait" (I am using document.write for this) and then open a
new url with some lengthy calculation process so the page will load in
a few seconds.
The <body onload="redirect()"doesn't work for me in this case, so I
thought that if I update current page with new text no harm would be
done. It works, but now the user will have a new page in the history
with the same url as previous but different contents ("Please, wait"
paragraph). I thought that browser keeps history based on new URLs,
but looks like it's not true. How can I overwrite the content of a
page without causing a new entry in the browser history?

Thank you,
Andrew

Mar 26 '07 #1
6 2568
ASM
Trastabuga a écrit :
On the current page the user is at I need to write something like
"Please, wait" (I am using document.write for this) and then open a
new url with some lengthy calculation process so the page will load in
a few seconds.
The <body onload="redirect()"doesn't work for me in this case, so I
thought that if I update current page with new text no harm would be
done. It works, but now the user will have a new page in the history
with the same url as previous but different contents ("Please, wait"
paragraph). I thought that browser keeps history based on new URLs,
but looks like it's not true. How can I overwrite the content of a
page without causing a new entry in the browser history?
function wait() {
var wait = document.createElement('H1');
wait.style.textAlign = 'center';
wait.style.color = 'red';
wait.style.background = '#ddd";
wait.style.width = '100%';
wait.style.position = 'absolute';
wait.style.top = '50px';
wait.innerHTML = 'Please Wait'
document.body.appendChild(wait);
}

insteed of :
document.body.appendChild(wait);
you can have :
document.getElementById('someWhere').appendChild(w ait);
if you want your message in div 'someWhere'
and if this div is positioned

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 26 '07 #2
"Trastabuga" <li*******@gmail.comwrote in message
news:11*********************@o5g2000hsb.googlegrou ps.com...
On the current page the user is at I need to write something like
"Please, wait" (I am using document.write for this) and then open a
new url with some lengthy calculation process so the page will load in
a few seconds.
The <body onload="redirect()"doesn't work for me in this case, so I
thought that if I update current page with new text no harm would be
done. It works, but now the user will have a new page in the history
with the same url as previous but different contents ("Please, wait"
paragraph). I thought that browser keeps history based on new URLs,
but looks like it's not true. How can I overwrite the content of a
page without causing a new entry in the browser history?
Add content to existing text nodes, or add a text node then write to it.

-Lost
Mar 27 '07 #3
ASM said the following on 3/26/2007 7:28 PM:
Trastabuga a écrit :
>On the current page the user is at I need to write something like
"Please, wait" (I am using document.write for this) and then open a
new url with some lengthy calculation process so the page will load in
a few seconds.
The <body onload="redirect()"doesn't work for me in this case, so I
thought that if I update current page with new text no harm would be
done. It works, but now the user will have a new page in the history
with the same url as previous but different contents ("Please, wait"
paragraph). I thought that browser keeps history based on new URLs,
but looks like it's not true. How can I overwrite the content of a
page without causing a new entry in the browser history?

function wait() {
var wait = document.createElement('H1');
Are you sure that the name of a function being the name of a variable is
a good idea?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 27 '07 #4
ASM
Randy Webb a écrit :
ASM said the following on 3/26/2007 7:28 PM:
>>
function wait() {
var wait = document.createElement('H1');

Are you sure that the name of a function being the name of a variable is
a good idea?
Ooops !
I though I did correct : function waiter() { ... }
before to post :-(

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 27 '07 #5
ASM
Randy Webb a écrit :
ASM said the following on 3/26/2007 7:28 PM:
>>
function wait() {
var wait = document.createElement('H1');

Are you sure that the name of a function being the name of a variable is
a good idea?
Not too much,
but as the variable 'wait' doesn't go away form function 'wait',
here it is OK.

Test with some correction(s) of typo :

<html>
<script type="text/javascript">
function wait() {
var wait = document.createElement('H1');
wait.style.textAlign = 'center';
wait.style.color = 'red';
wait.style.background = '#ddd';
wait.style.width = '100%';
wait.style.position = 'absolute';
wait.style.top = '50px';
wait.innerHTML = 'Please Wait'
document.body.appendChild(wait);
}
wait();
</script>
</html>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 27 '07 #6
ASM said the following on 3/27/2007 10:41 AM:
Randy Webb a écrit :
>ASM said the following on 3/26/2007 7:28 PM:
>>>
function wait() {
var wait = document.createElement('H1');

Are you sure that the name of a function being the name of a variable
is a good idea?

Not too much,
but as the variable 'wait' doesn't go away form function 'wait',
here it is OK.
It may be ok "here" but it isn't a good practice/habit to form.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 27 '07 #7

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

Similar topics

3
by: Phil Schmidt | last post by:
I'm trying to make a custom entry widget, as in the code that follows. There are two problems I'm trying to fix: 1) I would like the widget to behave as myEntry.Escape() does now, except that it...
4
by: Bernard | last post by:
Hi, I am suddenly getting Safari script errors with the following user agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML, like Gecko) Safari/125.8 In a...
2
by: Bruce | last post by:
I have sucessfully used document.write in a new window, but I now wish to write to an already open & framed window. How do I do it. Please show example, as I have trouble getting my head around JS....
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
7
by: Andrea | last post by:
Hi there - I'm hoping someone can help me; I've been struggling with this for a few days! :-) I have a webpage that is comprised of many forms containing questions. As the user answers one...
10
by: MLH | last post by:
I wish to give someone an A97 database they can install on their PC as a runtime application. I want them to click a button on a form (frmDocumentMyPC). I want to document as much useful...
11
by: Tony | last post by:
Is it me, or is document.write just about the most abused js function? Maybe, like goto, js would be better without it? Is there any good reason to use it? Because I'm having a hard time seeing...
4
by: Narven | last post by:
Hi, I've been creating a script that dynamic loads js files. but after creating that script, (and i use document.createElement('script');) in that function.. i've realise that the code that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.