Button doing work as a hot link ??

21 views
Skip to first unread message

Mel Smith

unread,
Jun 14, 2013, 10:36:50 PM6/14/13
to
Hi:

I'll be placing a 'hot link' on my developing page.

But, I wish it to be a *button* (rather than an anchor <a >) whereby I
can capture the 'click', then do my 'click-counting' and other work, then
send the hot-link on its way to fruition.

I googled around and found that the following code that looks promising,
but I couldn't get it to work.

In IE8 nothing happened after the click. With Chrome and FF the screen
cleared but went to sleep.

Is there something obvious I'm doing wrong ?

btw, I've now forgotten where I found this code :(

Below is a stripped-down version of what I'm trying (& failing) to do.

Thank you.

-Mel Smith


************************************
HTML:

<div id="ihoturl">
<form id="ihotlink" action="http://www.google.com">
<input type="button" onclick="gohotlink()" value="Visit the WebSite" />
</form>
</div>

JS:

function gohotlink() {
var linkobj = getobj("ihotlink") ;
linkobj.submit() ;
}

**********************************


Denis McMahon

unread,
Jun 15, 2013, 2:05:10 AM6/15/13
to
On Fri, 14 Jun 2013 20:36:50 -0600, Mel Smith wrote:

> <div id="ihoturl">
> <form id="ihotlink" action="http://www.google.com">
> <input type="button" onclick="gohotlink()" value="Visit the WebSite" />
> </form>
> </div>
>
> JS:
>
> function gohotlink() {
> var linkobj = getobj("ihotlink") ;
> linkobj.submit() ;
> }
>
> **********************************

See http://www.sined.co.uk/tmp/urlbutton.htm for a couple of alternative
approaches you could use.

--
Denis McMahon, denismf...@gmail.com

Jukka K. Korpela

unread,
Jun 15, 2013, 4:53:39 AM6/15/13
to
2013-06-15 5:36, Mel Smith wrote:

> I'll be placing a 'hot link' on my developing page.

This looks a bit like trolling.

> But, I wish it to be a *button* (rather than an anchor <a >) whereby I
> can capture the 'click', then do my 'click-counting' and other work, then
> send the hot-link on its way to fruition.

And you don't think you can have an onclick event in <a>? Or do you want
to prevent Google & competitors from following the link, at any cost?
You could use a <span> element with onclick, or you could use a <form>
with <input type=button> or <button type=button>, but do you fear that
Google might some was recognize the construct as a link and follow it?

> btw, I've now forgotten where I found this code :(

This is compatible with the trolling hypothesis.

> var linkobj = getobj("ihotlink") ;

Where might getobj() be defined? What does the console say?

--
Yucca, http://www.cs.tut.fi/~jkorpela/

JJ

unread,
Jun 15, 2013, 6:49:09 AM6/15/13
to
On Fri, 14 Jun 2013 20:36:50 -0600, Mel Smith wrote:
> But, I wish it to be a *button* (rather than an anchor <a >) whereby I
> can capture the 'click', then do my 'click-counting' and other work, then
> send the hot-link on its way to fruition.

By "click-counting", if you meant do access a counter URL before navigating
to the link URL, the code needs to add a hidden IFRAME and when it's
finished loading, navigate to the link URL.

> I googled around and found that the following code that looks promising,
> but I couldn't get it to work.
[snip]
> JS:
>
> function gohotlink() {
> var linkobj = getobj("ihotlink") ;
> linkobj.submit() ;
> }

With that code alone, it'll never work in any web browser. getobj is not
defined anywhere. Insert this function before the gohotlink function:

function getobj(n) {
return document.getElementById(n);
}

Or simply replace the gohotlink function with this one:

function gohotlink() {
var linkobj = document.getElementById("ihotlink");
linkobj.submit();
}

Mel Smith

unread,
Jun 15, 2013, 10:53:35 AM6/15/13
to
Denis said:

> See http://www.sined.co.uk/tmp/urlbutton.htm for a couple of alternative
> approaches you could use.

Thanks for the page Denis. I'll look at it today.

-Mel


Mel Smith

unread,
Jun 15, 2013, 11:10:34 AM6/15/13
to
Jukka said:
> This looks a bit like trolling.

Why do you have to ascrive bad motives to me ??

> This is compatible with the trolling hypothesis.

Again !

(This hot link will be to my future users' *own* web site. I would like
*him* to know when and how many times his link on *my* site has been
'clicked' by someone visiting my site. Its also a learning experience for
me too. )

>
>> var linkobj = getobj("ihotlink") ;
>
> Where might getobj() be defined? What does the console say?

function getobj(cid) {
return document.getElementById(cid) ;
}


another btw, I run three other web sites from my own Apache server.
They are all pro bono. Whether the current one under development will be
too, I'm not sure.

Re: Trolling/Attacking Over the last year or so, I've been DoS
attacked many times on my other sites, and have consequently used 'Deny From
www.xxx.yyy.zzz' for many of these attacking IPs. My current developing
site is only allowed access from myself --- at least for a few more months

A troll I am not !


-Mel




Mel Smith

unread,
Jun 15, 2013, 11:27:31 AM6/15/13
to
JJ said:

> With that code alone, it'll never work in any web browser. getobj is not
> defined anywhere. Insert this function before the gohotlink function:
>
> function getobj(n) {
> return document.getElementById(n);
> }
>
> Or simply replace the gohotlink function with this one:
>
> function gohotlink() {
> var linkobj = document.getElementById("ihotlink");
> linkobj.submit();
> }

Hi JJ:

Of course, I defined getobj() exactly as you noted above, but failed to
include its definition in my example. I have used this for a few months
now. It prevents a lot of typing errors for me.


Because 1/2 of the time I work/develop in another C-based language (the
Harbour language --- xHarbour), I make many mistakes when moving from
Harbour to JavaScript several times a day. So, I created some utility
string functions (inter alia) for JS that emulate some those functions in
Harbour:

Here are a few below the starred line.

I must say tho that I miss the '$' operator in Javascript. In my
harbour language, it is implemented as follows:

lFoundit := "MEL" $ upper("isthatmelana##holeorwhat") //
looking for letters 'mel' in string
// lFoundit returns true (or in harbour --- .T.)

So, I use the function partof() below as a substitute

-Mel


*****************************
function setfocus(cid) {
document.getElementById(cid).focus();
}

function len(str) {
if (str && typeof str === "string") {
return str.length;
}
else return 0 ;
}


function alltrim(str) {
return str.replace(/^\s+|\s+$/g,"") ;
}

function empty(str) {
if (typeof str === "string" && str.length === 0) return true ;
if (typeof str === "number" && str.value === 0) return true ;
return false ;
}

function partof(c,str) {
return (str.indexOf(c) !== -1) ? true : false ;
}

function left(cstr,numchars) {
if (typeof cstr === "string" && typeof numchars === "number") return
cstr.substr(0,numchars) ;
return cstr ;
}

function right(cstr,numchars) {
if (typeof cstr === "string" && typeof numchars === "number") return
cstr.substring(cstr.length-numchars,cstr.length) ;
return cstr ;
}

function upper(cstr) {
return cstr.toUpperCase() ;
}

function lower(cstr) {
return cstr.toLowerCase() ;
}




Jukka K. Korpela

unread,
Jun 15, 2013, 12:23:33 PM6/15/13
to
2013-06-15 18:10, Mel Smith wrote:

> A troll I am not !

Thank you for confirming the trolling hypothesis so clearly.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

Mel Smith

unread,
Jun 15, 2013, 12:35:44 PM6/15/13
to
Denis said:

> See http://www.sined.co.uk/tmp/urlbutton.htm for a couple of alternative
> approaches you could use.


Hi Denis:

I looked and downloaded, and implemented :))

That is exactly what I wanted ---- i.e., window.location = url

I'll embellish on that for the next few days. I think that when the
link is clicked, I should be able to send back to my server (by/thru Ajax
??) that the link to this club was clicked, and then do the database
recording / analyzing at my server. Hmmmm ...

Thanks again (and btw, my mobile home community in Arizona uses the
results of your work (two years ago) every working day and I made them aware
many months ago of your contribution. I spend about 1/2 hour per day
checking/updating the mesaeastpark.com site with new info -- your help to me
and them is very much appreciated).

-Mel


Mel Smith

unread,
Jun 15, 2013, 3:09:42 PM6/15/13
to
Jukka said:
> Thank you for confirming the trolling hypothesis so clearly.
>

One common definition of trolling is:


1. trolling Share on twitter Share on facebook Share on more 8662 up,
5997 down
Being a prick on the internet because you can. Typically unleashing one
or more cynical or sarcastic remarks on an innocent by-stander, because it's
the internet and, hey, you can.
Guy: "I just found the coolest ninja pencil in existence."
Other Guy: "I just found the most retarded thread in existence."


So, I don't believe I fall within the bounds of the above definition of
'trolling'. If *you* think I do, then maybe *you* have that problem instead
of me.

-Mel



ViLco

unread,
Jul 9, 2013, 4:24:04 AM7/9/13
to
Mel Smith wrote:

> Because 1/2 of the time I work/develop in another C-based language (the
> Harbour language --- xHarbour),
> // lFoundit returns true (or in harbour --- .T.)
>
> So, I use the function partof() below as a substitute

> function len(str) {

> function alltrim(str) {

> function empty(str) {

> function partof(c,str) {

> function left(cstr,numchars) {

> function right(cstr,numchars) {

> function upper(cstr) {

> function lower(cstr) {

From what I read here this xHarbour isn't C-based, it's Foxpro based
--
"Un pasto senza vino e' come un giorno senza sole"
Anthelme Brillat Savarin


Mel Smith

unread,
Jul 9, 2013, 11:50:39 AM7/9/13
to
ViLco said:
> From what I read here this xHarbour isn't C-based, it's Foxpro based


[OT] follows:

Hi ViLco:

No, harbour prgs are 'compiled' into C source code. Then, those .c files
are compiled into .obj files, then the object files are linked (along with
70+ librairies) into a .exe executable file.

Of course, many years ago, the languages Foxbase / FoxPro / Clipper /
dBase III / xBase, etc all served as a foundation for the modern Extended
Harbour language starting back in 2001. But now, along with this powerful
language we are able thru Replaceable Data Drivers (RDDs) to accommodate
almost any modern database system (including various SQL data drivers).

btw, I use a harbour .exe as my CGI app for web sites. This app builds
pages, accesses databases, inserts JS, etc, etc, then sends the page to my
Apache Server for transmission to the client. This app of course also
quickly responds to AJAX calls, building a string packet to pass back to
the client

-Mel


ViLco

unread,
Jul 10, 2013, 7:39:02 AM7/10/13
to
Thanks, it's interesting news
Reply all
Reply to author
Forward
0 new messages