Click to See Complete Forum and Search --> : location / script from a link - how to do it right?


getho
07-16-2003, 09:55 PM
Howdy,

I've written some kindergarden javascript for a site to do a really simple booking form. It uses session cookies and it works OK BUT in mozilla (1.3) theres a few weirdnesses. There are 2 buttons for each course (10 courses to a page). you click the 1st and it writes a cookie, click another and it
writes another. Clicking the 2nd button also re-directs to the booking form.

I had attached the action to a mouseup on a href to the booking form page, but in mozilla and netscape it would execute the javascipt and then always go to the booking form (not what I wanted). So currently theres just a "#" as the link. But Mozilla 1.3 takes 3 clicks on the 2nd choice before it
will go to the booking form.

the script uses this
location.href = "booking-form.html";
to get to the booking form. Is it possible thats the problem??

page is here... http://www.campcreative.com.au/courses-visual-arts.html

the top course has the new link, the others have the old.

I've taught myself this stuff so I may be doing something horrible. Please let me know!

Gethin

BTW I thought a correct null link was "javascript;" when I do that mozilla tries to run a script called ";"!

badda
07-16-2003, 10:22 PM
Im not sure, what you're actually trying to do ...
write a cookie and then redirect to the booking page?
well, anyways... If I was you, I would call the script within the href attribute.
Looks something like this:
<A
href="javascript:writeCookie('A7');
document.location.href='booking-form.html'"
>

BTW: An empty link is
<a href="javascript:void(0)">

Hope that was any help ..

Sebastian

pyro
07-16-2003, 10:31 PM
You can also do this for an empty link, though the above is valid:

<a href="#">

Note that unless you return false in your onclick handler, that will take you to the top of the page...

getho
07-16-2003, 10:43 PM
Thanks folks, as usual an element of your replies put me onto it and as usual it was a tiny thing.. I was using location.href = "booking...
mozilla and net 7 wanted
document.location.href = "booking...

another BTW I've got a varibale name with a number in it. Is that kosha? ("var = cookievar2")

thanks for the replies,

Getho

pyro
07-16-2003, 10:49 PM
Yes, numbers are fine in variables... Also, instead of document.location.href, you may want to use top.location.href (in case frames are ever an issue) or window.location.href

getho
07-16-2003, 11:20 PM
thanks pyro - the site is frame free, but I'll try to lodge it in my head..

Geth