The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 23, 2019, 06:02:09 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: document.referer  (Read 9517 times)
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« on: September 24, 2007, 05:53:42 AM »

JS moron here.

I want to put this on my homepage:

<script type="text/javascript" src="perlcounter.cgi"></script>


so I did. Cheesy

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="perlcounter.cgi?referer"></script>

I tried putting just document.referer there? doh

<script type="text/javascript" src="perlcounter.cgi?document.referrer"></script>

But that just sent document.referrer LOL

HEEEEELLLLLPPPP


Bompa




Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
JasonD
Expert
****
Offline Offline

Posts: 100


View Profile
« Reply #1 on: September 24, 2007, 08:00:58 AM »

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

Code:

<script>
document.write ('<scri'+ipt src = "http://www.domain.dom/cgi-bin/script.pl?'+document.referer+'&othervariable='+other.variable+'"></scr'+ipt>');
</script>
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: September 24, 2007, 08:47:07 AM »

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

Code:
<script>
newNode = document.createElement('script');
scriptCall = 'perlcounter.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
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #3 on: September 24, 2007, 01:56:19 PM »

thanks
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #4 on: September 24, 2007, 03:14:27 PM »

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

Code:

<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.  Cheesy

Bompa
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
JasonD
Expert
****
Offline Offline

Posts: 100


View Profile
« Reply #5 on: September 25, 2007, 02:05:49 AM »

Bomps.

I fucked up the syntax and missed a couple of quotes here n there Smiley

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

Posts: 164


JTFC


View Profile
« Reply #6 on: October 09, 2007, 12:26:45 PM »

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
Logged

Spontaneity has it's time and place.  [Sluggo, 1990-ish]
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #7 on: October 09, 2007, 01:08:18 PM »

Lotsa folks will watch for the word "script" on a parameter and kill it.
Separating it makes it more difficult for regexes and such to see the word in an inbound parameter.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #8 on: October 09, 2007, 01:46:06 PM »

Yeah obfuscating your script tags is the first step towards social network trickery  Angel
Logged

hai
jairez
Expert
****
Offline Offline

Posts: 164


JTFC


View Profile
« Reply #9 on: October 09, 2007, 02:19:23 PM »

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
Logged

Spontaneity has it's time and place.  [Sluggo, 1990-ish]
Dragonlaird
Rookie
**
Offline Offline

Posts: 15


Working with AJAX before it even had a name...


View Profile
« Reply #10 on: October 20, 2007, 02:36:22 AM »

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.
Logged

No links in signatures please
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!