/    Sign up×
Community /Pin to ProfileBookmark

location / script from a link – how to do it right?

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… [url]http://www.campcreative.com.au/courses-visual-arts.html[/url]

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 “;”!

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@baddaJul 17.2003 — 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
Copy linkTweet thisAlerts:
@pyroJul 17.2003 — 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...
Copy linkTweet thisAlerts:
@gethoauthorJul 17.2003 — 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
Copy linkTweet thisAlerts:
@pyroJul 17.2003 — 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
Copy linkTweet thisAlerts:
@gethoauthorJul 17.2003 — thanks pyro - the site is frame free, but I'll try to lodge it in my head..

Geth
×

Success!

Help @getho spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...