Thread: document.referer
Bompa

JS moron here.

I want to put this on my homepage:

<script type="text/

javascript

 " src="

perl

 counter.cgi"></script>


so I did. Applause

But I want to send additional info in the query string, like the http_referer,
but I cant see how to do that.


So, I want to have something like this:

<script type="text/

javascript

 " src="

perl

 counter.cgi?referer"></script>

I tried putting just document.referer there? doh

<script type="text/

javascript

 " src="

perl

 counter.cgi?document.referrer"></script>

But that just sent document.referrer LOL

HEEEEELLLLLPPPP


Bompa




JasonD

Perk will moan at me as I am not doing it in an OO dynamic script tag way



<script>
document.write ('<scri'+ipt src = "http://www.domain.dom/cgi-bin/script.pl?'+document.referer+'&othervariable='+other.variable+'"></scr'+ipt>');
</script>

perkiset

Actually JD, best tool for the job and all... yours is tight and clean. Here it is in a DOM kind of way:


<script>
newNode = document.createElement('script');
scriptCall = '

perl

 counter.cgi?dr=' + document.referrer;
if ((document.all) && (document.getElementById))
{
// IE
newNode.src = scriptCall;
} else {
// Everyone else
newNode.setAttribute('src', scriptCall);
}
var target = document.getElementsByTagName('body');
target[0].appendChild(newNode);
</script>


Cool Bomps! Getting a little more client side action eh? Look forward to helping you with that...

/p

Bompa

thanks

Bompa

quote author=JasonD link=topic=522.msg3388#msg3388 date=1190646058

Perk will moan at me as I am not doing it in an OO dynamic script tag way



<script>
document.write ('<scri'+ipt src = "http://www.domain.dom/cgi-bin/script.pl?'+document.referer+'&othervariable='+other.variable+'"></scr'+ipt>');
</script>



Hey Jason, I tried yours first cuz it's the simplest for me to

learn

  from, but it didn't work.  I am
wondering about all those single quotes.   Like <scri will print literally, but then + ipt src =  with
no quotes, huh?  If it's not insided quotes it's taken as a variable I thought.

Anyways, I get the concept of what you are doing and I'm currently fiddling with it.  Applause

Bompa

JasonD

Bomps.

I fished up the syntax and missed a couple of quotes here n there Applause

quote

<script>
document.write ('<scri'+'ipt src = "http://www.domain.dom/cgi-bin/script.pl?'+document.referer+'&othervariable='+other.variable+'"></scr'+'ipt>');
</script>

jairez

I've looked at this thread a couple of times now, mostly to see how Perk did his OO magic, when I finally noticed JD separated the <><script> tag. 

q:  what does that do or prevent from happening?

Curious & thanx.

/ja

perkiset

Lotsa folks will watch for the word "script" on a parameter and kill it.
Separating it makes it more difficult for

regex

 es and such to see the word in an inbound parameter.

vsloathe

Yeah obfuscating your script tags is the first step towards social

net

 work trickery  Applause

jairez

Aaahhh .... that's totally cool!  I never thought of that --- I feel like such a Dorothy <>(sans Toto) when it comes to this stuff.

q:  are there other tags I should be aware of?

DULSM-GMLO.

  /ja

Dragonlaird

quote author=perkiset link=topic=522.msg3576#msg3576 date=1191960498

Lotsa folks will watch for the word "script" on a parameter and kill it.


In addition, many code editors (and browsers) see the script tag embedded in quotes and don't realise it's meant to be a string, they try executing the code within the tag and die horribly (since it isn't complete and wouldn't make sense to a browser at this stage).

Similarly, you should always separate the end tag in a similar way to stop the browser from closing your real script tag prematurely.


Perkiset's Place Home   Politics @ Perkiset's