473,320 Members | 1,854 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,320 software developers and data experts.

replace method

Hello and thanks in advance for the help.

I have been looking for a way to easily eliminate or disable the "Back"
button on some of my web pages. I was reading my Javascript for Dummies
Quick Reference and came upon the replace method. The book says:

"The replace() method of the location object replaces the current history
entry with the specified URL."

"The upshot is that after JavaScript scalls the replace() method, the new
URL loads, and the user can no longer navigate to the previously loaded URL
by clicking the back button."

It seems to me that this could be an elegant way to achieve my objective.
Can someone tell this novice a little more about how this method is used?

I am also open to other suggestions for accomplishing the same objective.

Many thanks,
Jeff
Jul 23 '05 #1
7 1573
Jeff Grippe wrote:
Hello and thanks in advance for the help.

I have been looking for a way to easily eliminate or disable the
"Back" button on some of my web pages.


You can open the page in a new window, it will not have a history.

Anyway the back button is an important part of the browser user interface.
Disabling it is actually a bad idea as you try to take control over the
user's possibilities. I can't imagine a situation where this is really
needed. Also you will get in trouble with browsers that attempt to protect
users from such things (popup blockers and things like that).

So it is better to spend your time for enhancing the usability of your
website the way that the back button can be normally used.

--
Markus
Jul 23 '05 #2
Jeff Grippe wrote:
Hello and thanks in advance for the help.

I have been looking for a way to easily eliminate or disable the "Back"
button on some of my web pages. I was reading my Javascript for Dummies
Quick Reference and came upon the replace method. The book says:

"The replace() method of the location object replaces the current history
entry with the specified URL."

"The upshot is that after JavaScript scalls the replace() method, the new
URL loads, and the user can no longer navigate to the previously loaded URL
by clicking the back button."

It seems to me that this could be an elegant way to achieve my objective.
Can someone tell this novice a little more about how this method is used?
It isn't, because visitors hate it. Anyone with JavaScript disabled
or not available wont have the URL replaced anyway.

Why do you want to stop navigation back to the current page?

<URL:http://www.w3.org/QA/Tips/reback>

I am also open to other suggestions for accomplishing the same objective.


1. Ask your users not to use the back button.

2. Change your site navigation so that whatever issue makes you want
to break the back button is avoided.
--
Rob
Jul 23 '05 #3

"RobG" <rg***@iinet.net.auau> wrote in message
news:42***********************@per-qv1-newsreader-01.iinet.net.au...
1. Ask your users not to use the back button.

I have but they sometimes do anyway.
2. Change your site navigation so that whatever issue makes you want
to break the back button is avoided.


My users are entering transactions which are end up in my database. They
have five or six items to enter. Each entry redirects to the next script
until they finally get to the last item that they must enter where they have
a set of Submit/Cancel/Start Over buttons.

I want them to go through the sequence in the order specified. Each of the
six steps has the Submit/Cancel/Start Over buttons. If they want to start
over then I want them to use the Start Over button which takes care of clean
up that is necessary. The same is true for cancel.

I need to control the sequence of events because some of the items depend on
other items. Some need to be checked at submit time. There is some setup
required before the first item. There are all sorts of reasons why I need to
control the flow of the information entry.

Thanks for the help.

Regards,
Jeff
Jul 23 '05 #4
Jeff Grippe wrote:

My users are entering transactions which are end up in my database.
They have five or six items to enter. Each entry redirects to the
next script until they finally get to the last item that they must
enter where they have a set of Submit/Cancel/Start Over buttons.


Start over is actually annoying if you just want to rethink what you entered
the page before.

I suggest to solve the problem in your server side application. I think that
most or all common server side scripting languages support sessions. Store
the entered data in a session, then you can change it if the user goes back
and changes his/her mind. Then at the end of the transaction show a summary
of all entered data and ask the user to confirm it, then store it in the
database.

HTH
Markus
Jul 23 '05 #5


Nothing to it, location.replace('YOURURLHERE'); it loads the new file in
the browser but it doesn't add it to the window.history object, so,
there's a Back button, but is greyed out if there's no window.history,
there might be some history, but the one url that loaded off
location.replace(), won't show there. If you are the webserver
administrator, there are ways to send http-headers to the client to tell
it not to cache or you can also just use a session if mild-security is the
issue, no js needed.
Danny

On Thu, 23 Jun 2005 07:14:06 -0700, Jeff Grippe <jg*****@hilldun.com>
wrote:
Hello and thanks in advance for the help.

I have been looking for a way to easily eliminate or disable the "Back"
button on some of my web pages. I was reading my Javascript for Dummies
Quick Reference and came upon the replace method. The book says:

"The replace() method of the location object replaces the current history
entry with the specified URL."

"The upshot is that after JavaScript scalls the replace() method, the new
URL loads, and the user can no longer navigate to the previously loaded
URL
by clicking the back button."

It seems to me that this could be an elegant way to achieve my objective.
Can someone tell this novice a little more about how this method is used?

I am also open to other suggestions for accomplishing the same objective.

Many thanks,
Jeff


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #6
Jeff Grippe wrote:
"RobG" <rg***@iinet.net.auau> wrote in message
news:42***********************@per-qv1-newsreader-01.iinet.net.au...

1. Ask your users not to use the back button.

I have but they sometimes do anyway.

2. Change your site navigation so that whatever issue makes you want
to break the back button is avoided.

My users are entering transactions which are end up in my database. They
have five or six items to enter. Each entry redirects to the next script
until they finally get to the last item that they must enter where they have
a set of Submit/Cancel/Start Over buttons.

I want them to go through the sequence in the order specified. Each of the
six steps has the Submit/Cancel/Start Over buttons. If they want to start
over then I want them to use the Start Over button which takes care of clean
up that is necessary. The same is true for cancel.

I need to control the sequence of events because some of the items depend on
other items. Some need to be checked at submit time. There is some setup
required before the first item. There are all sorts of reasons why I need to
control the flow of the information entry.


Perhaps XMLHttpRequest will do the job. As each section is completed,
send the data back to your server and present the next section based on
the content delivered from the previous send. The data itself can be
cached in the page in hidden fields or on your server.

You could provide an 'in-page' back button that goes back up the
sections, clearing the hidden elements for each section so users can go
back to fix previous sections. If you are caching at the server,
keeping the sessions synchronised will require a bit of thought.

But for non-JavaScript visitors, you will need to present a navigable
version that goes to the server for every section - sessions have been
suggested.

--
Rob
Jul 23 '05 #7

"RobG" <rg***@iinet.net.auau> wrote in message
news:vs******************@news.optus.net.au...
Perhaps XMLHttpRequest will do the job. As each section is completed,
send the data back to your server and present the next section based on
the content delivered from the previous send. The data itself can be
cached in the page in hidden fields or on your server.

You could provide an 'in-page' back button that goes back up the
sections, clearing the hidden elements for each section so users can go
back to fix previous sections. If you are caching at the server,
keeping the sessions synchronised will require a bit of thought.

But for non-JavaScript visitors, you will need to present a navigable
version that goes to the server for every section - sessions have been
suggested.


My scripting language does support sessions. The way I'm considering dealing
with this at the moment would be to create a session variable that tells me
where in the process I am. At the top of each session I would put some
script code with checks that session variable and loads the correct script
along with a reminder that things must be done in sequence.

Thanks for the help.

Jeff
Jul 23 '05 #8

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

Similar topics

12
by: Barnes | last post by:
Does anyone know of a good way to use the JavaScript string.replace() method in an ASP form? Here is the scenario: I have a form that cannot accept apostrophes. I want to use the replace() so...
1
by: Thomas | last post by:
It looks like the String.replace doesn't work in IE6.1. Anyone else has the same problem. I am using newest service package of IE and Win2K. Thanks
2
by: Barnes | last post by:
Hi, Can anyone please tell me how I can use the replace method to replace a character if it occures in more than one textbox without having to write separate function for each textbox. The...
24
by: Wim Roffal | last post by:
Is there a possibility to do a string replace in javascript without regular experessions. It feels like using a hammer to crash an egg. Wim
4
by: Cor | last post by:
Hi Newsgroup, I have given an answer in this newsgroup about a "Replace". There came an answer on that I did not understand, so I have done some tests. I got the idea that someone said,...
1
by: JAG | last post by:
I am getting an error using the replace method in one of my functions. I am using the replace method in the mail document function in my frameset .hta to change forward slashes to back slashes in...
3
by: TOXiC | last post by:
Hi everyone, First I say that I serched and tryed everything but I cannot figure out how I can do it. I want to open a a file (not necessary a txt) and find and replace a string. I can do it...
5
by: V S Rawat | last post by:
I was trying to use back-to-back replace functions to convert a url: str1 = str.replace("%2F","/").replace("%3F","?").replace("%3D","=").replace("%2 6","&"); It didn't replace all 4 types of...
10
by: Lonifasiko | last post by:
Hi, Just want to replace character at index 1 of a string with another character. Just want to replace character at that position. I thought Replace method would be overloaded with an index...
1
by: NvrBst | last post by:
I want to use the .replace() method with the regular expression /^ %VAR % =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)" regular expression with "":...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.