Click to See Complete Forum and Search --> : return to privious page
PGMR_1998
07-03-2003, 09:06 AM
i have a very short piece of code that branches to another url, but when it brances, you cannot get back to the previous page when you hit the back button. it becomes locked on the branched page. my code is:
function getPDF() {
url = "00A2001";
url = "http://intranet/legal/opinions/" + url + ".pdf";
document.write ("<meta http-equiv='refresh' content='1; url=" + url + "'>");
location.href = url
}
This line:
document.write ("<meta http-equiv='refresh' content='1; url=" + url + "'>");
is going to be filling your history with the current page -- one a second. So, if you are on the page for 15 seconds, you will have to hit back 15 times to get out...
PGMR_1998
07-03-2003, 09:46 AM
how can i avoid this? i want to hit the back button and actually go to the previous page regardless of time.
You'll have to remove the meta refresh. You could try something like this:
<script type="text/javascript">
function reloadPage() {
window.location.replace(window.location);
}
setTimeout("reloadPage()", 1000);
</script>
PGMR_1998
07-03-2003, 10:27 AM
when i remove the refresh, i must hit the back button twice. the first time it returns to a blank screen. the second time it then returns to the previous page. maybe i should open a second window for the branch, that way the user does not have to hit the back button, but simply close the window. how could i open a second window for the url to display its content?
The code I posted should work fine.
PGMR_1998
07-03-2003, 11:02 AM
i have tried your code and it does work. however, here is my case:
i have an html with a submit button. when i press the submit button, a javascript function is called that will cause a pdf document to load by using a meta tag. this works fine except you cannot branch back to the current page when the back button is clicked. when i remove the refresh option from the mata tag, i can branch back, but i must hit the back button twice. the first time it returns to a blank page. the second click of the back button then gets me back to the original page. how can i avoid seeing the blank page and why is it showing up? thanks so very much...
As I said above, don't use the meta refresh. This should work:
function getPDF() {
url = "00A2001";
window.location.href = "http://intranet/legal/opinions/" + url + ".pdf";
}
PGMR_1998
07-03-2003, 11:30 AM
this code simply reloads the current html document and never goes to the pdf. here is the code:
function getPDF() {
url = "00A2001";
window.location.href = "http://intranet/legal/opinions/" + url + ".pdf";
}