473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Link to run script and link to page

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
Jul 20 '05 #1
3 2787
In article <66**************************@posting.google.com >,
mr*************@hotmail.com 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

Jul 20 '05 #2
On 13 Jan 2004 13:14:55 -0800, Carl Gilbert <mr*************@hotmail.com>
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
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #3
Lee
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">

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Andrew Chalk | last post by:
Is this possible? In my CGI app. I display a web page with a link (anchor). When the link is clicked I want to exectute a python script rather than go to an HTML page. Many thanks.
1
by: Andrew V. Romero | last post by:
I have a script that I am working on for an intranet tool and in this script I have a form, which when submitted the onSubmit command calls calculate(). In this calculate function, I have it do...
4
by: KS | last post by:
Im trying to prevent the user from clicking any other links on my page when the user have selected/clicked a href once. Sometimes it takes a while before the next page loads so some user will try...
8
by: CHouck | last post by:
I have what seems to be a simple problem but I can't figure it out. I have a page where I have a link with variables built in which I want to pass through the URL so another page can pick the...
6
by: SF RVN | last post by:
Hmmmm.. a wee bit of a problem: Background default.htm has a left-aligned table serving as a 'navigation menu' and a right-aligned iFrame (named 'viewframe') serving as the 'target' for...
3
by: JohnEGee | last post by:
Hello, all, and TIA for any help you can offer. I've searched the Internet for answers and have finally come here. I've created a page (several, actually) with a link that opens a pop-up...
0
by: llarryllama | last post by:
I'm using this script (see below) that I found here on thescripts and it's working perfectly. It's to change text color of a "visited link" back to unvisited color. The problem is that to make the...
2
by: zglazer | last post by:
Hi -- I'm working on a website that uses Javascript and CSS to show or hide portions of text on each page. There's a sort of table of contents at the top of each page, and rather than using anchor...
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
14
by: Wouter | last post by:
Hi, I try to make the follow. I want that i can click on a text link and that then a link wil be copyed in a input form box (<input type="text" name="img_url" />). I have google-ed about how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.