Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Link to run script and link to page

Reply
Thread Tools

Link to run script and link to page

 
 
Carl Gilbert
Guest
Posts: n/a
 
      01-13-2004
Hi

How can I use a link to both run a peice of script and link to another page?

So far I have the following:

-----------------------------------------------------------------------

<A href="javascript:GetCookie('linkcookie')">add 1 to linkcookie</A>

-----------------------------------------------------------------------

Many thanks, Carl Gilbert
 
Reply With Quote
 
 
 
 
Lee
Guest
Posts: n/a
 
      01-13-2004
Carl Gilbert said:
>
>Hi
>
>How can I use a link to both run a peice of script and link to another page?
>
>So far I have the following:
>
>-----------------------------------------------------------------------
>
><A href="javascript:GetCookie('linkcookie')">add 1 to linkcookie</A>


<a href="http://www.myotherpage.com"
onclick="GetCookie('linkcookie');return true">

 
Reply With Quote
 
 
 
 
kaeli
Guest
Posts: n/a
 
      01-13-2004
In article <(E-Mail Removed) >,
http://www.velocityreviews.com/forums/(E-Mail Removed) enlightened us with...
> Hi
>
> How can I use a link to both run a peice of script and link to another page?


Assuming DOM browsers (easier that way). If you need to support older
browsers such as NN4, do not do this.
Older browsers do not support onClick of A.


>
> <A href="javascript:GetCookie('linkcookie')">add 1 to linkcookie</A>


<a href="link.html" onClick="GetCookie('linkcookie');">add</a>


--
--
~kaeli~
Why do people who know the least know it the loudest?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      01-13-2004
On 13 Jan 2004 13:14:55 -0800, Carl Gilbert <(E-Mail Removed)>
wrote:

> How can I use a link to both run a peice of script and link to another
> page?
>
> So far I have the following:
>
> <A href="javascript:GetCookie('linkcookie')">add 1 to linkcookie</A>


You shouldn't use javascript: URIs. They can cause a lot of problems.
Instead, use the onclick intrinsic event. This has the added advantage, in
your case, that it frees up the href attribute and allows it to be used
properly. For example,

<A href="newPage.html" onclick="GetCookie('linkcookie')">Add 1 to
linkcookie</A>

For future reference: when clicked, the above link will first execute the
JavaScript function in the onclick event attribute, then navigate to
newPage.html. If you want to only execute the onclick event code, place a
'return false' statement after the code. For example,

<A href="somePage.html" onclick="someFunction(); return false">Some
link</A>

The primary purpose of a link like the one above is to provide
functionality for users who might not have JavaScript enabled (a sizable
portion of WWW users). With JavaScript enabled, someFunction() will be
executed. Without it, the user will be taken to somePage.html.

Hope I explained that adequately,

Mike

--
Michael Winter
(E-Mail Removed)d (replace ".invalid" with ".uk" to reply)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute a script from another script and other script does notdo busy wait. Rajat Python 3 01-08-2010 02:05 PM
RE: How to execute a script from another script and other script doesnotdo busy wait. VYAS ASHISH M-NTB837 Python 2 01-07-2010 08:18 PM
Run a python script as an exe and run a new process from it venutaurus539@gmail.com Python 9 02-27-2009 05:22 PM
run a script and supply commands from a python cgi script moishyyehuda@gmail.com Python 1 12-14-2006 05:16 PM
Passing value from one script on one page to another script on another page. Robert Cohen ASP General 3 07-15-2003 01:46 PM



Advertisments