Redirect Script Compatibility

C

crjunk

I don't know much about java scripts, but here is my attempt to write
one. My script allows the user to enter their customer number into a
textbox. When they click on a button, they are redirected to a PDF
file. So if my customer number is 12345, I will be directed to
http://www.websiteaddress.com/reports/12345.pdf whenever I type my
customer number into the textbox.

The script I wrote works with IE 6.0, but when I tested it with
Netscape 4.7, it would not work. I'm not familiar with java scripts
and browser compatibilities. Can someone take a look at my script and
tell me what I need to change in this script to make it compatible
with as many browsers as possible?

Thanks!

<HTML>
<HEAD>
<TITLE>View Report</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function GetReport() {
self.location.href = 'http://www.websiteaddress.com/reports/' +
document.forms[0].txtValue.value + '.pdf';
}
// -->
</SCRIPT>
</HEAD>
<BODY>
<form ID="Form1">
<input type=text name=text1 size=30 ID="txtValue">
<input type=button value="View Report" onClick="GetReport()"
ID="Button1" NAME="btnView">
</form>
</BODY>
</HTML>
 
L

Lee

crjunk said:
I don't know much about java scripts, but here is my attempt to write
one. My script allows the user to enter their customer number into a
textbox. When they click on a button, they are redirected to a PDF
file. So if my customer number is 12345, I will be directed to
http://www.websiteaddress.com/reports/12345.pdf whenever I type my
customer number into the textbox.

The script I wrote works with IE 6.0, but when I tested it with
Netscape 4.7, it would not work. I'm not familiar with java scripts
and browser compatibilities. Can someone take a look at my script and
tell me what I need to change in this script to make it compatible
with as many browsers as possible?

The way that you're referencing the fields actually uses
the NAME attribute, but you're specifying the ID value.
IE lets you get away with many things that other browsers
won't.

They shouldn't really be called "java scripts".
The JavaScript language has nothing to do with the Java language.
 
C

crjunk

Can someone provide an alternative piece of code that will accomplish this?

Thanks for your help!

crjunk
 

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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top