Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Can a Hyperlink call a Javascript confirm prompt?

Reply
Thread Tools

Can a Hyperlink call a Javascript confirm prompt?

 
 
Chris Ianson
Guest
Posts: n/a
 
      03-17-2006
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.


 
Reply With Quote
 
 
 
 
Chris Ianson
Guest
Posts: n/a
 
      03-18-2006
Any ideas guys?

"Chris Ianson" <> wrote in message
news:v2HSf.37635$ k...
> 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.
>



 
Reply With Quote
 
 
 
 
Vic Sowers
Guest
Posts: n/a
 
      03-18-2006

"Chris Ianson" <> wrote in message
news:v2HSf.37635$ k...
> 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?')"



 
Reply With Quote
 
Chris Ianson
Guest
Posts: n/a
 
      03-18-2006
"Vic Sowers" <Mail@Vic_NOSPAM_Sowers.com> wrote in message
news:WMSSf.4850$...
> 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.


 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      03-18-2006
Chris Ianson wrote:

> "Vic Sowers" <Mail@Vic_NOSPAM_Sowers.com> wrote in message
> news:WMSSf.4850$...
>
>>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
 
Reply With Quote
 
Chris Ianson
Guest
Posts: n/a
 
      03-18-2006
Thank Jonathan, that was very helpful of you.


 
Reply With Quote
 
Dr John Stockton
Guest
Posts: n/a
 
      03-19-2006
JRS: In article <>, dated Sat, 18 Mar
2006 06:22:19 remote, seen in news:comp.lang.javascript, Thomas
'PointedEars' Lahn <> 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.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
 
Reply With Quote
 
Chris Ianson
Guest
Posts: n/a
 
      03-19-2006
"Jonathan N. Little" <> wrote in message
news:441c1496$0$3708$.. .

> <!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?


 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      03-19-2006
Chris Ianson wrote:
> "Jonathan N. Little" <> wrote in message
> news:441c1496$0$3708$.. .
>
>> <!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?
>
>


If you add a 'target' attribute to your link on a page that is NOT
contained in frames it will open a new window, i.e., a popup window....

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
Chris Ianson
Guest
Posts: n/a
 
      03-19-2006
"Jonathan N. Little" <> wrote in message
news:441de80c$0$3701$.. .

> If you add a 'target' attribute to your link on a page that is NOT
> contained in frames it will open a new window, i.e., a popup window....


Yep that I know, but there are many links on this page and none of them are
blocked by Google's popup blocker, except the one with the code you gave for
the confirmation prompt. Bizarre.


 
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
Call Javascript confirm from code behind tshad ASP .Net 3 03-25-2010 01:55 PM
how can I pass javascript window.confirm result back to my perl cgiprogram Grehom Perl Misc 2 05-14-2008 04:00 PM
How to add a hyperlink column to asp.net datagrid - where only one value is a hyperlink davetichenor ASP .Net 1 10-30-2006 02:57 PM
Can a Hyperlink call a Javascript confirm prompt? Chris Ianson Javascript 17 03-20-2006 05:45 AM
Can you rename the buttons on confirm() call? Chris Markle Javascript 6 01-29-2005 02:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57