473,545 Members | 721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document referrer

does anyone know if there is anything wrong with this code? <SCRIPT
LANGUAGE="JavaS cript">document .referrer.index Of("http://www.example.com ")
!= -1){ document.write( "http://www.example.com/image1.jpg")} </SCRIPT>

?
Sep 28 '06 #1
5 11002
or how to property set document.referr er, would something like this work:

<SCRIPT LANGUAGE="JavaS cript">
{
document.referr er == 'http://www.example.com ;
document.write( '<img src=http://www.example.com/image1.jpg width="60"
height="60">');

}
</SCRIPT>
"Nospam" <no****@home.co mwrote in message
news:Zj******** ***********@new sfe5-win.ntli.net...
does anyone know if there is anything wrong with this code? <SCRIPT
LANGUAGE="JavaS cript">document .referrer.index Of("http://www.example.com ")
!= -1){ document.write( "http://www.example.com/image1.jpg")} </SCRIPT>

?


Sep 28 '06 #2
Nospam wrote on 28 Sep 2006 in comp.lang.javas cript:
or how to property set document.referr er, would something like this
work:
<SCRIPT LANGUAGE="JavaS cript">
use:

<script type='text/javascript'>
{
no need for the {
document.referr er == 'http://www.example.com ;
You forgot the closing apostrophe of the string:

document.referr er == 'http://www.example.com ';

Are you sure document.referr er would not return:
'http://www.example.com/'
or
'http://www.example.com/index.html'
etc?

Or do you want to test true for any referrer from that domain?

The double '==' compares the two strings, but you do not use the result.

Do you mean:

if (document.refer rer == 'http://www.example.com ')
document.write( '...

??

document.write( '<img src=http://www.example.com/image1.jpg width="60"
height="60">');
I would enclose the URL string in quotes
scr="http://www.example.com/image1.jpg"
width="60"
height="60"
Use css styles:

style='width:60 px;height:60px'

>
}
no need for that }
</SCRIPT>
===============

I would suggest the following:

<script type='text/javascript'>

var url = 'http://www.example.com ';
var s = "<img src='"+url+"/image1.jpg'";
s += " style='width:60 px;height:60px' >";

if (document.refer rer.substr(0,ur l.length) == url)
document.write( s);

</script>

not tested

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sep 28 '06 #3
Nospam said the following on 9/28/2006 8:46 AM:
or how to property set document.referr er, would something like this work:
Did you test it? You didn't or you wouldn't be asking that question.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 28 '06 #4

Nospam wrote:
does anyone know if there is anything wrong with this code? <SCRIPT
LANGUAGE="JavaS cript">document .referrer.index Of("http://www.example.com ")
!= -1){ document.write( "http://www.example.com/image1.jpg")} </SCRIPT>
The language attribute is deprecated, use type instead:

<script type = "text/javascript">
>From what I gather, you're saying if I didn't come from the example
site, then you're gonna take and use their content. I would say that's
the only thing wrong with your code. And it's not foolproof, meaning I
could come from different site, and there would be no way that you
could cover all the cases. I don't even have to come from a site. I
can just launch an empty window, and navigate to your site. In which
case, document.referr er would be empty.

Sep 28 '06 #5

Nospam wrote:
or how to property set document.referr er, would something like this work:
document.referr er == 'http://www.example.com ;
1. The referrer property is a read-only value.
2. You're doing an equality comparison.
3. Even if referrer wasn't read-only, and you were doing an assignment,
then you have an unterminated string.

Sep 28 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3236
by: Daniel | last post by:
Hi, All! I have a problem - I manage two websites, with two different style sheets (one for each site), but they both share hte same public message boards and I want to change the CSS used by the forumn template depending on which site the user came from - this must be done in JScript, as the boards are hosted offsite and we cannot edit the...
9
3052
by: goks | last post by:
I'm using document.referrer method for tracking visits on my site. But it seems that, when someone finds my site with google, this method returns only: "google.com/search?q=xxxxx" (good) or "google.com/search?hl=en" (bad) or "google.com/search?sourceid=navclient" (bad) That meens, it returns only first parameter sent to google. "hl"...
1
2977
by: kuok benny | last post by:
Hi, I am trying to use the document.referrer to get the referrer of my home page. Occationally, I get the value of 'blockedReferrer'. Actually how this happen, how the client blocked the function of document.referrer. I just want to verify how this could be done within the browser e.g. IE, Netcape and so on... what Internet option have...
9
14383
by: Frances Del Rio | last post by:
if I put alert(document.referrer) in code of a file that was linked from another it returns blank... pls, need to get document.referrer, don't why it's not working... read up on oreilly, don't know what I'm doing wrong.. thank you.. Frances
2
2359
by: Goober | last post by:
I have to determine the document.referrer of the individual coming to my site. I want to send everyone not coming from one of those sites to an alternate location (The names below are just used as examples). I want to match on one of those names anywhere in the document.referrer. In the main program I call a subroutine like this: <script...
2
10266
by: X l e c t r i c | last post by:
Hi, I'm trying to put the last URL visited to a text input using history.previous for WebTV (because I can't get document.referrer to work with WebTV) and document.referrer for PC. This is for my Web Resources page. Where if I go straight to it from an image that I want to edit with an online imaging tool, or if I go straight to it from a...
1
2758
by: Mike Dee | last post by:
Hi All - I'm having a strange problem I'm wondering if anyone can shed some light on. When I use ASP or ASP.NET code to get the referrer information from the server side, it comes back as null. However in these same cases document.referrer returns the valid referrer. What could cause this? In other words, with the following line: ref =...
1
2132
by: gocre8 | last post by:
hope someone can advise! . . . i'm using this code... <SCRIPT LANGUAGE="JavaScript"> document.write("<INPUT type=hidden NAME=referrer VALUE=" + 'document.referrer' + ">"); </SCRIPT> to generate a hidden field to be submitted with a php formmail script, so i know from which url the visitor has filled in the form. this works well,...
0
7465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7752
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.