473,651 Members | 3,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can a Hyperlink call a Javascript confirm prompt?

Hi, I have this JavaScript, which I only want to occur if a user clicks on a
hyperlink hotspot in a large image:

<script type="text/javascript">
<!--
var answer = confirm ("This link is not available, click OK to load a
similar link, or Cancel to not.")
if (!answer)
window.location ="http://www.yahoo.com/"
// -->
</script>

To make matters more challenging, there are about 10 hotspots in the image,
and I want them each to have a different value for window.location . I.e. if
the user clicks OK in each hotspot, each one will redirect them to a
different site.

Any clever-clogs out there who can help out? :)

Thanks in advance.
Mar 17 '06 #1
17 3844
Chris Ianson wrote:
Hi, I have this JavaScript, which I only want to occur
Probably you mean "execute".
if a user clicks on a hyperlink hotspot in a large image:

<script type="text/javascript">
<!-- ^^^^
Nonsense.
var answer = confirm ("This link is not available, click OK to load a
similar link, or Cancel to not.")


Utter nonsense. What about users without client-side script support? If you
discover that a link does not work, remove it (the link, not necessarily
its content). If you want to work around broken links until you have time
to fix them (one way or the other), do that server-side, not (only)
client-side.

And stop crossposting to alt.* and the Big Eight (incl. comp.*).
PointedEars
Mar 18 '06 #2
Any ideas guys?

"Chris Ianson" <no***@hotmail. com> wrote in message
news:v2******** *********@text. news.blueyonder .co.uk...
Hi, I have this JavaScript, which I only want to occur if a user clicks on
a hyperlink hotspot in a large image:

<script type="text/javascript">
<!--
var answer = confirm ("This link is not available, click OK to load a
similar link, or Cancel to not.")
if (!answer)
window.location ="http://www.yahoo.com/"
// -->
</script>

To make matters more challenging, there are about 10 hotspots in the
image, and I want them each to have a different value for window.location .
I.e. if the user clicks OK in each hotspot, each one will redirect them to
a different site.

Any clever-clogs out there who can help out? :)

Thanks in advance.

Mar 18 '06 #3

"Chris Ianson" <no***@hotmail. com> wrote in message
news:v2******** *********@text. news.blueyonder .co.uk...
Hi, I have this JavaScript, which I only want to occur if a user clicks on
a hyperlink hotspot in a large image:

<script type="text/javascript">
<!--
var answer = confirm ("This link is not available, click OK to load a
similar link, or Cancel to not.")
if (!answer)
window.location ="http://www.yahoo.com/"
// -->
</script>

To make matters more challenging, there are about 10 hotspots in the
image, and I want them each to have a different value for window.location .
I.e. if the user clicks OK in each hotspot, each one will redirect them to
a different site.

Any clever-clogs out there who can help out? :)

Thanks in advance.


Try setting the href="http://www.yahoo.com/" and onClick="return confirm("Do
you really want Yahoo?')"

Mar 18 '06 #4
"Vic Sowers" <Mail@Vic_NOSPA M_Sowers.com> wrote in message
news:WM******** ********@tornad o.texas.rr.com. ..
Try setting the href="http://www.yahoo.com/" and onClick="return
confirm("Do you really want Yahoo?')"


Thanks Vic but I'm quite new to this. Could you kindly show me the exact
code to 'copy and paste'? Then I can understand it for next time. Not sure
about onClick etc. Thanks again. :)
Mar 18 '06 #5
Chris Ianson wrote:
"Vic Sowers" <Mail@Vic_NOSPA M_Sowers.com> wrote in message
news:WM******** ********@tornad o.texas.rr.com. ..
Try setting the href="http://www.yahoo.com/" and onClick="return
confirm("Do you really want Yahoo?')"

Thanks Vic but I'm quite new to this. Could you kindly show me the exact
code to 'copy and paste'? Then I can understand it for next time. Not sure
about onClick etc. Thanks again. :)


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test Confirm Box</title>
</head>
<body>
<h1>Test Confirm</h1>
<p>
To test how code a confirm on click,
click <a href="http://www.yahoo.com/"
onclick="return confirm('Do you really want Yahoo?')">
Go To Yahoo</a>
</p>
</body>
</html>

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Mar 18 '06 #6
Thank Jonathan, that was very helpful of you.
Mar 18 '06 #7
JRS: In article <14************ ****@PointedEar s.de>, dated Sat, 18 Mar
2006 06:22:19 remote, seen in news:comp.lang. javascript, Thomas
'PointedEars' Lahn <Po*********@we b.de> posted :

And stop crossposting to alt.* and the Big Eight (incl. comp.*).


There's nothing wring with that by Big-8 rules.

German hierarchy rules are irrelevant here.

Please stop being a Kontrol Freak, and engage a good psychiatrist.

As you must realise, I don't find German quick to read. Are users of
de.c.l.j as disgusted with your arrogance as so many of us here are
(ISTM from what they post that they may well be? Perhaps MH would
venture an unprejudiced opinion.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demo n.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Mar 19 '06 #8
"Lee" <RE************ **@cox.net> wrote in message
news:dv******** *@drn.newsguy.c om...
Why not just set the HREF of these AREA tags to the URL that you're
going to send them to, and simply cancel the click if they choose
cancel:

<area href="http://www.yahoo.com"
onclick="return confirm('this link is ..., or cancel')">


Thanks for the very helpful reply Lee.
Mar 19 '06 #9
"Jonathan N. Little" <lw*****@centra lva.net> wrote in message
news:44******** **************@ news.centralva. net...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test Confirm Box</title>
</head>
<body>
<h1>Test Confirm</h1>
<p>
To test how code a confirm on click,
click <a href="http://www.yahoo.com/"
onclick="return confirm('Do you really want Yahoo?')">
Go To Yahoo</a>
</p>
</body>
</html>


Hmm, any idea why some popup blockers such as Google's seem to block the
link from opening when OK is clicked?
Mar 19 '06 #10

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

Similar topics

1
5060
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when they press "Cancel" they call another ASPX function. My code now is: System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf) System.Web.HttpContext.Current.Response.Write("if (confirm('Are you sure you want to...
4
1841
by: Don Grover | last post by:
I hope some one can help, I have a html table that is created with asp that has a row of repeated buttons down the side. these call a page passing a query string with invoice number. I need to get a Java Yes/No dialog up and on yes call the hyperling query string. I can do this with a single hyperlink but not passing on the query string and invnumber Here is my Response Write link
2
10112
by: neoconwannabe | last post by:
Hi, I have an html form with a number of checkboxes that can be checked to delete items. I want to have a javascript alert prompt box to pop up to confirm the delete. I am building my site with javascript as an enhancement and not a requirement to work. My question is can I have the html form function normally if the user has javascript
6
16096
by: Chris Markle | last post by:
Javascript confirm call outputs a dialogue box that writes out a message and gives two choices: OK and Cancel. Can those buttons be relabelled say to "Yes" and "No"?
1
6518
by: Pat | last post by:
All, What I want to do: ******************* Click on a hyperlink in the last column in a datagrid, have it grab a value in the fourth column in the same row and send it to the codehind into a function that will then put the value into a query and send it off the database.... and do some stuff with the return. What I have so far:
6
1813
by: sck10 | last post by:
Hello, Can you control the window attributes (toolbar, scrollbars, left and right exc.) when using the hyperlink control as you would when using javascript? For examle, I am using the following javascript to open another window and would like to control these attributes with the hyperlink control: window.open(msgSubmitterInfo,t,s);return false" var s="toolbar=no,directories=no,scrollbars=yes,resizable=yes,"; s+= ...
9
2324
by: RA | last post by:
While dynamically creating the table; I am adding a hyperlink as a TableCell where text is "Delete". Initially it is disabled and if a checkbox is selected from a table then it gets enabled. Even though it is disabled, if I click on that cell it fires onClick event. The other concern is it does not show Hand as its cursor; which we would expect from a hyperlink. (NOTE: I am also adding hyperlinks to few other TableCells, which are not...
3
7884
by: J.P. Cummins | last post by:
In my ASP.NET application, I wish to have a page for administrators to edit items in a list. Preferably, I would like to use the javascript prompt for the 'rename' function, and a javascript alert box for the 'delete' function. When the user clicks 'rename', the javascript prompt asks for the new name. When the user clicks 'delete', a javascript alert asks the user if he really wants to delete that item. Here is an example of what my...
19
3480
by: Joe | last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first column contains hyperlinks. When a user clicks one of these hyperlinks, he will navigate to another aspx page (referred to here as page_2). I need to cache the value of the link's text (hyperlink.text property) so that I can use it in the page_load event of page_2. I've thought of using a hidden field and then calling Request.Form("hdnClickedLinkText") in the...
0
8278
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7299
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.