my script doesn't work.... sigh!

L

Luca

About one month ago I have inserted in my web site a
clickcounter who controls the access to almost every link, but this script
who changed the path in every link so the
search engines couldn't recognize my links and my web site has lost a lot in
search engines ranks;
this is the script:


<A href="http://www.mywebsite.com/cgi-bin/click/go.cgi?http://www.fiao.it"
Target="_blank">
F.I.A.O.
</A>

<p class=notasxinf>
<script
src="http://www.mywebsite.com/cgi-bin/click/stats.cgi?url=http://www.fiao.it
&type=js"> <!this script send the number to the counter>
</script>
accessi dal 13/12/2003
</p>

Last week a person said to me to insert this javascript to solve all off my
problems (I'm a javascript begginner):


<a href="http://www.fiao.it" (here I added: target="_blank")
onclick="self.location.href='http://www.mywebsite.com/cgi-bin/click/go.cgi?h
ttp://www.fiao.it'; return false">
FIAO.it </A>
and to mantein the other script:

<p class=notasxinf>
<script
src="http://www.mywebsite.com/cgi-bin/click/stats.cgi?url=http://www.fiao.it
&type=js"> <!this script send the number to the counter>
</script>
accessi dal 13/12/2003
</p>

Whith this script though I have added: target="_blank", i couldn't raise to
have the second window opened so I changed a little the javascript (I'm a
javascript begginner) in this way:

<a href="http://www.fiao.it" target="_blank"
onclick="window.open(self.location.href='http://www.mywebsite.com/cgi-bin/cl
ick/go.cgi?http://www.fiao.it'; return false)">
FIAO
</A>

at the beginning it looks to work, so I inserted it in almost all my site
(working hard during two days), but half an hour ago I have discovered it
doesn't work:
Now a new window open, but the counter does not count!!!
Every one can say to me where is the error in this last my script, or better
which script I need to use to obtain the result to count clicks, to open the
site in a new window and to left a copy of the link that could be read by
search engine (possibly without using the noscript tag)?

thanks lot to every who answer this may question
bye luca (from Italy).
 
@

@SM

Luca a ecrit :
About one month ago I have inserted in my web site a
clickcounter who controls the access to almost every link, but this script
who changed the path in every link so the
search engines couldn't recognize my links and my web site has lost a lot in
search engines ranks;
this is the script:

<A href="http://www.mywebsite.com/cgi-bin/click/go.cgi?http://www.fiao.it"
Target="_blank">
F.I.A.O.
</A>

<p class=notasxinf>
<script
src="http://www.mywebsite.com/cgi-bin/click/stats.cgi?url=http://www.fiao.it
&type=js"> <!this script send the number to the counter>
</script>
accessi dal 13/12/2003
</p>

Last week a person said to me to insert this javascript to solve all off my
problems (I'm a javascript begginner):

<a href="http://www.fiao.it" (here I added: target="_blank")
onclick="self.location.href='http://www.mywebsite.com/cgi-bin/click/go.cgi?h
ttp://www.fiao.it'; return false">
FIAO.it </A>
and to mantein the other script:

<p class=notasxinf>
<script
src="http://www.mywebsite.com/cgi-bin/click/stats.cgi?url=http://www.fiao.it
&type=js"> <!this script send the number to the counter>
</script>
accessi dal 13/12/2003
</p>

Whith this script though I have added: target="_blank", i couldn't raise to
have the second window opened so I changed a little the javascript (I'm a
javascript begginner) in this way:

<a href="http://www.fiao.it" target="_blank"
onclick="window.open(self.location.href='http://www.mywebsite.com/cgi-bin/cl
ick/go.cgi?http://www.fiao.it'; return false)">
FIAO
</A>

at the beginning it looks to work, so I inserted it in almost all my site
(working hard during two days), but half an hour ago I have discovered it
doesn't work:
Now a new window open, but the counter does not count!!!
Every one can say to me where is the error in this last my script, or better
which script I need to use to obtain the result to count clicks, to open the
site in a new window and to left a copy of the link that could be read by
search engine (possibly without using the noscript tag)?

thanks lot to every who answer this may question
bye luca (from Italy).

Do not understand why you want to open in a new window ... ? !
Perhaps is it why it doesn't work ?
You call a cgi and you don't know how it runs !
It would be preferable to do not open it in a new window.
Certainly on fiao.it they have a FAQ about their counter.
Try to do exactly what they say, before to test other ways ... !

in your code to open a new window there are some mistakes :

Correct it like that :

<a href="http://www.fiao.it" target="_blank"
onclick="
window.open('http://www.mywebsite.com/cgi-bin/click/go.cgi?http://www.fiao.it');
return false;">FIAO</A>

You could try :

<a href="http://www.mywebsite.com/cgi-bin/click/go.cgi?http://www.fiao.it"
target="vinivici" onclick="window.open('','vinivici');">FIAO</A>

or :

<a href="http://www.mywebsite.com/cgi-bin/click/go.cgi?http://www.fiao.it"
target="vinivici" onclick="window.open('','vinivici','resizable=1,menubar=1');">FIAO</A>

or (for a full screen) (very not recommanded ! )

<a href="http://www.mywebsite.com/cgi-bin/click/go.cgi?http://www.fiao.it"
target="vinivici" onclick="window.open('','vinivici','width='+
screen.width-26+',height='+screen.height-50+',resizable=1,top=0,left=0');">FIAO</A>

--
******** (enlever/remove [OTER_MOI] du/from reply url) *******
Stéphane MORIAUX : mailto:[email protected]
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephane.moriaux/internet/
**************************************************************
 
M

Michael Winter

<a href="http://www.xyzwebsite.com/"
onclick="window.open('http://mywebsite.com/cgi-bin/click/go.cgi?http://www.x
yzwebsite.com/'); return false;">
xyzwebsite</a>

Can you tell me if this script could have any problem?

The window.open() method requires two arguments. The first (which you
have) is the URI of the document to load. The second is the name of the
new window, which can be used with the target attribute in links. Even if
you never intend to use the name, you should supply it - even 'w' would be
fine. I think some browsers refuse to open the window if you don't.

Mike
 
L

Luca

The window.open() method requires two arguments. The first (which you
have) is the URI of the document to load. The second is the name of the
new window, which can be used with the target attribute in links. Even if
you never intend to use the name, you should supply it - even 'w' would be
fine. I think some browsers refuse to open the window if you don't.


So the script would be this? ---> (inserting target="_blank")

<a href="http://www.xyzwebsite.com/" target="_blank"
onclick="window.open('http://mywebsite.com/cgi-bin/click/go.cgi?http://www.x
yzwebsite.com/'); return false;">
xyzwebsite</a>

if not what could be (sorry i'm a javascript beginner :) )

thanks, bye

Luca
 
M

Michael Winter

So the script would be this? ---> (inserting target="_blank")

<a href="http://www.xyzwebsite.com/" target="_blank"
onclick="window.open('http://mywebsite.com/cgi-bin/click/go.cgi?http://www.x
yzwebsite.com/'); return false;">
xyzwebsite</a>

if not what could be (sorry i'm a javascript beginner :) )

The HTML is fine. I was referring to the JavaScript call. You currently
have

window.open('URL');

What you need is

window.open('URL', 'windowName');

So, using your current example (omitting the URL for clarity), we have:

<a href="http://www.xyzwebsite.com/"
onclick="window.open('theURL', 'xyzwebsite'); return false">...</a>

If you did want to direct a page opened by a link to the new window, you
could do:

<a href="http://www.example.com/" target="xyzwebsite">...</a>

Notice that the values of the target attribute, and the second argument to
window.open(), are the same.

Mike
 
L

Luca

Notice that the values of the target attribute, and the second argument to
window.open(), are the same.


So I need to use both target="_Newwindow" and the second argumento of
window.open ?

<a href="http://www.xyzwebsite.com/" target="_Newwindow"
onclick="window.open('theURL', 'xyzwebsite'); return false">...</a>

or is enough:


<a href="http://www.xyzwebsite.com/"
onclick="window.open('theURL', 'xyzwebsite'); return false">...</a>


And I 've seen a little particular in your script:

I need to remove the semicolon at the end of the script? ----> ); return
false;">...</a> to make so (i had read is better to put it there) : ---> );
return false">..</a>
thanks, bye
luca
 
L

Luca

Notice that the values of the target attribute, and the second argument to
window.open(), are the same.


So I need to use both target="_Newwindow" and the second argumento of
window.open ?

<a href="http://www.xyzwebsite.com/" target="_Newwindow"
onclick="window.open('theURL', 'xyzwebsite'); return false">...</a>

or is enough:


<a href="http://www.xyzwebsite.com/"
onclick="window.open('theURL', 'xyzwebsite'); return false">...</a>


And I 've seen a little particular in your script:

I need to remove the semicolon at the end of the script? ----> ); return
false;">...</a> to make so (i had read is better to put it there) : ---> );
return false">..</a>
thanks, bye
luca
 
M

Michael Winter

Sorry, I shouldn't have introduced the target attribute to the discussion.
So I need to use both target="_Newwindow" and the second argumento of
window.open ?

<a href="http://www.xyzwebsite.com/" target="_Newwindow"
onclick="window.open('theURL', 'xyzwebsite'); return false">...</a>

or is enough:

<a href="http://www.xyzwebsite.com/"
onclick="window.open('theURL', 'xyzwebsite'); return false">...</a>

The second example (without the target attribute) is sufficient.

And I 've seen a little particular in your script:

I need to remove the semicolon at the end of the script?

No, you don't. I just tend to. In an intrinsic event, you don't need to
include a semi-colon at the end of the last statement, but it is good
practice to add it. With scripts in general, you should always terminate
statements with a semi-colon.

Mike
 
L

Luca

I have inserted your suggestion in part of my today work and when I click on
the links the editor html said there is an error in the script:
The script I have tried now is this:

<a href="http://www.assoleader.it" target="_blank"
onclick="window.open('http://www.mywebsite.com/cgi-bin/click/go.cgi?http://w
ww.assoleader.it', '_blank'); return false;">
www.Assoleader.it .</A>

My html editor says there is an error at first letter of the line --->
onclick=....

I have also tried without target="_blank" and without the secon argument of
window.open. in all these cases the editor I use says there is an error in
javascript code.

I don't know what to do: now i'm thinking to leave all in the same manner it
was:

<a href="http://www.assoleader.it"
onclick="window.open('http://www.mywebsite.com/cgi-bin/click/go.cgi?http://w
ww.assoleader.it'); return false;">
www.Assoleader.it .</A>


bye ,
Luca
 
L

Luca

Sorry i hadn't read your last message, but I must confirm that my editor
(first page2000 says theree is an error in the script) also with this kind
of script (though the script
works):

a href="http://www.xyzwebsite.com/"
onclick="window.open('theURL', 'xyzwebsite'); return false">...</a>

so i don't know what to do!!?

thanks all the same,
Luca
 
M

Michael Winter

Sorry i hadn't read your last message, but I must confirm that my editor
(first page2000 says theree is an error in the script) also with this
kind
of script (though the script
works):

a href="http://www.xyzwebsite.com/"
onclick="window.open('theURL', 'xyzwebsite'); return false">...</a>

so i don't know what to do!!?

Create this as a HTML file. Tell me if you have problems with it.

<html lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>Test page</title>
</head>
<body>
<div>
<a href="http://www.google.com/"
onclick="window.open(this.href,'Google');return false;">test</a>
</div>
</body>
</html>

Mike

Just so you know: using this.href as I did above is the same as using
'http://www.google.com/'
 
L

Luca

I have tried what you said, but it looks be the same, but i think what you
say be the just thing because I have seen my editor tell me there is an
error when I'm off line (and it cannot tell me what kind of error!), but
when i'm on line, if I press a link in the editor, the referring web sites
open in a new window without problems... so i think maybe is a problem of my
editor.

I'm courious to understan something of your last message:
Can i put this href again after the script path, like this:

<a href="http://www.assoleader.it"
onclick="window.open('http://www.mywebsite.com/cgi-bin/click/go.cgi?http://t
his.href', 'w'); return false;">
www.Assoleader.it .</A> ?

Is it always necessary to put this in the "head" (I hadn't this (but whit,
or without I have seen no changes are):
<meta http-equiv="Content-Script-Type" content="text/javascript">
?

However I'm very happy to have found you so patient!
thanks lot ,
bye,
Luca
 
L

Luca

I have tried what you said, but it looks be the same, but i think what you
say be the just thing because I have seen my editor tell me there is an
error when I'm off line (and it cannot tell me what kind of error!), but
when i'm on line, if I press a link in the editor, the referring web sites
open in a new window without problems... so i think maybe is a problem of my
editor.

I'm courious to understan something of your last message:
Can i put this href again after the script path, like this:

<a href="http://www.assoleader.it"
onclick="window.open('http://www.mywebsite.com/cgi-bin/click/go.cgi?http://t
his.href', 'w'); return false;">
www.Assoleader.it .</A> ?

Is it always necessary to put this in the "head" (I hadn't this (but whit,
or without I have seen no changes are):
<meta http-equiv="Content-Script-Type" content="text/javascript">
?

However I'm very happy to have found you so patient!
thanks lot ,
bye,
Luca
 
M

Michael Winter

[snip]
I'm courious to understan something of your last message:
Can i put this href again after the script path, like this:

<a href="http://www.assoleader.it"
onclick="window.open('http://www.mywebsite.com/cgi-bin/click/go.cgi?http://t
his.href', 'w'); return false;">
www.Assoleader.it .</A> ?

Yes, but with a slight difference. this.href yields a string, so you would
concatenate it. For example,

<a href="http://www.assoleader.it/"
onclick="window.open('http://www.mywebsite.com/cgi-bin/click/
go.cgi?'+this.href,'w');return false;">www.Assoleader.it</a>

would be the same as

<a href="http://www.assoleader.it/"
onclick="window.open('http://www.mywebsite.com/cgi-bin/click/
go.cgi?http://www.assoleader.it/','w');return false;">www.ass
oleader.it</a>

Line wrapping can be a pain sometimes, can't it. :)
Is it always necessary to put this in the "head" (I hadn't this (but
whit, or without I have seen no changes are):
<meta http-equiv="Content-Script-Type" content="text/javascript">
?

Strictly, if you use intrinsic events, such as onclick, you should include
that META element. It indicates the language used in the event code.
However, most (possibly all) browsers just assume JavaScript anyway so in
practice it's not really necessary. Because I try to conform to the
various specifications as best I can, I use that META element nevertheless.

Mike
 
L

Luca

Thanks Mike javascript seems to be very interesting...
i'm trying to learn it and what you have explained to me was as very
interesting as to post on this newsgroup.
If I raise to learn enough this scripting language I would like to utilize
again this newsgroup: so I can exercize myself in writing english.
thanks and goodbye (arrivederci... really we say in this case: "a
risentirci" from "sentire" = to hear),
bye
Luca from Italy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top