Click to See Complete Forum and Search --> : location.href


PGMR_1998
07-02-2003, 04:38 PM
i call this function when a submit button is pressed. it sends me to another page. problem is, i get off the new page when i hit the back button. please help...
here is my code:

function getPDF() {
url = "00A2001";
url = "http://intranet/legal/opinions/" + url + ".pdf";
document.write ("<meta http-equiv='refresh' content='1; url=" + url + "'>");
location.href = url;
}

Jona
07-02-2003, 04:43 PM
Take off this line:


document.write ("<meta http-equiv='refresh' content='1; url=" + url + "'>");


[J]ona

PGMR_1998
07-03-2003, 08:25 AM
when i take off that line, it just sits at the current page, and never goes to the url.

steelersfan88
07-03-2003, 08:50 AM
function getPDF() {
url1 = "00A2001";
url = "http://intranet/legal/opinions/" + url1 + ".pdf";
window.location.href = url;
}


This should work!

PGMR_1998
07-03-2003, 08:56 AM
when i try this, it no longer branches to the url.

Jona
07-03-2003, 01:29 PM
Originally posted by PGMR_1998
when i try this, it no longer branches to the url.

If you were not calling your previous function before the page loaded, you'd realize that the page was wiped out because of your document.write() statement. The code posted by steelersfan89, and the suggestion I provided (which was the result of his code) will both work. (Although, the window part is not required, it will still work.)

[J]ona

PGMR_1998
07-03-2003, 02:34 PM
i have tried the suggested code, but i assure u it does not work. it loads the original screen. here is the suggested code that i used:

function getPDF() {
URL1 = "00A2001";
url = "http://intranet/legal/opinions/" + URL1 + ".pdf";
window.location.href = url;
}


<form method="POST" ><p>
<b>Please enter your opinion number and press the submit button:</b><p>

<input type="text" name="t1" size="8"></p>
<p><input type="submit" value="Submit" name="B1" style="color: #0000FF" onClick="getPDF()">
<input type="reset" value="Reset" name="B2" style="color: #0000FF"></p>
</form>

Jona
07-03-2003, 02:36 PM
Change:


<input type="submit" value="Submit" onClick="getPDF()">


To:


<input type="button" value="Submit" onClick="getPDF();">


[J]ona

PGMR_1998
07-03-2003, 02:47 PM
sir, i am eternally greatful. that works like a charm...

Jona
07-03-2003, 02:48 PM
Originally posted by PGMR_1998
sir, i am eternally greatful. that works like a charm...

Hehe, don't call me sir, please. I'm only fourteen! lol. But you're welcome nevertheless. ;)

[J]ona