Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript Error: OrderWin is not a function

Status
Not open for further replies.

JimJx

Technical User
Feb 16, 2001
202
US
I am using this script to open a new window with a URL in it:

<Script Language=&quot;JavaScript&quot;>
function OrderWin(url) {
winStats='toolbar=no,location=no,directories=no,menubar=no,'
winStats+='scrollbars=yes,resizable=yes,'
if (navigator.appName.indexOf(&quot;Microsoft&quot;)>=0) {
winStats+=',left=0,top=0'
}else{
winStats+=',screenX=0,screenY=0'
}
OrderWin=window.open(url,&quot;&quot;,winStats)
OrderWin.focus()
}
</script>

The button that calls it uses this:

<FORM Name=&quot;OpenWin&quot;>
<Input Type=&quot;button&quot; Value=&quot;Order&quot; onClick=&quot;javascript:OrderWin('</FORM>

There are multiple buttons on the page that do the same thing, except with different URLs. The first time a button is clicked, everything works perfectly. Any time after that I get an error in IE or NS.

Any ideas on what I am doing wrong with this or what I need to do to prevent the error message?

Thanks in advance,
Jim
 
Hi JimJx!
To say truth, I don't know exactly the reason of an error (I got it also) - had no time to play with it.
But when I changed <Input Type=&quot;button&quot;> to &quot;submit&quot; everything works - clicked dozens of times in IE, Opera, NN4.x and N6 :)

Andrew | starway@mail.com
 
Do you think it is perhaps that after the first time you run the function, you are actually redefiining the OrderWin function with this part:

OrderWin=window.open(url,&quot;&quot;,winStats)
OrderWin.focus()


If you try it with different variable names, does it work?Thos is about all I can see at this momment. Bj
b2 - benbiddington@surf4nix.com
 
Thank you to everyone who replied here and by email.

I changed it to submit as suggested and it works great. Don't have a clue why it doesn't work with button in there instead. Have said it before and will say it again, computers are strange.......

I did try it with different a couple different variable names, OrdWin, NewOrd, and a couple others, same issue.

No matter what the var name is, after changing to submit, they all worked.

Once again, Thanks! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top