473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

CSS-changes depending on document.refferer

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 serverside language.

Unfortunately, its been over two years since I undertook a serious JScript
project and cannot remember alot of what to do. I was planning on this:
<script language=JavaScript>
if (document.reffer="http://www.website1.com"){
document.write('<link rel="stylesheet"
href="http://www.website1.com/css/css.css" type="text/css">
}
else if (document.reffer="http://www.website2.com"){
document.write('<link rel="stylesheet"
href="http://www.website2.com/css/css.css" type="text/css">
}
else {
document.write('<link rel="stylesheet" href="css/css.css"
type="text/css">
}
</script>

Can anyone help?

Thanks!

Daniel
Jul 20 '05 #1
1 3226
Daniel wrote:
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 serverside language.

Unfortunately, its been over two years since I undertook a serious JScript
project and cannot remember alot of what to do. I was planning on this:
<script language=JavaScript>
if (document.reffer="http://www.website1.com"){
document.write('<link rel="stylesheet"
href="http://www.website1.com/css/css.css" type="text/css">
}
else if (document.reffer="http://www.website2.com"){
document.write('<link rel="stylesheet"
href="http://www.website2.com/css/css.css" type="text/css">
}
else {
document.write('<link rel="stylesheet" href="css/css.css"
type="text/css">
}
</script>

Can anyone help?


document.referrer instead of document.reffer is a start :)

The language attribute is deprecated, use the type attribute instead.

= is an assignment, == is a comparison of value.

Might be a better idea to include something in your links though. If a
link is activated via the Favorites/Bookmarks, then document.referrer
will be empty. Same if the URL is typed in.

For testing offline, be advised that document.referrer in IE will be
empty even when a link is clicked. If you open test1.html and link to
test2.html from local files, then test2.html's referrer property will be
empty instead of test1.html

<script type="text/javascript">
if (document.referrer == "Absolute URL to site1") {
//handle site 1 referral
}
if (document.referrer == "Absolute URL to site2") {
//handle site 2 referral
}
if (document.referrer == "") {
//handle no referral
}

--
Randy

Jul 20 '05 #2

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

Similar topics

59
by: Mason A. Clark | last post by:
Is there information content in this observation? use html tables for layout: http://www.microsoft.com and http://www.netscape.com uses styles: http://www.opera.com
1
by: Jocab | last post by:
Just had a look at the Wired.com site and it seems it's completely in XHTML and CSS. I don't understand this snippet of code on their homepage, though: <link rel="stylesheet" type="text/css"...
145
by: Mark Johnson | last post by:
Oddly enough, I found it difficult, using Google, to find a list of best-of sites based on the quality of their css packages. So I'd ask. Does anyone know of particularly good sites which are in...
1
by: Garmt de Vries | last post by:
For a long time, I've used CSS to style my webpages, but only for media "screen" and "print". Now I've started looking into styling them for other media like "projection" and "handheld". I'd be...
20
by: Tammy | last post by:
What would be a good alternative to using frames? I need something that will section my webpage into two halves and can change both frames on a single click. Thanks in Advance, Tammy
3
by: nick | last post by:
I have the following code in my master page: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
4
by: Mikaël PLOUHINEC | last post by:
Hello, I have created a master page with a css. How can I use css in the children pages? The css must be declared in the <head</headsection. Does I have to import all my css in my master? Is...
1
by: shapper | last post by:
Hello, I created a theme folder where I place my Skin and CSS files. I have 5 files: Base.skin, Base.css, Default.css, Contacts.css, Print.css Base Skin and CSS files should be used on...
11
by: New Bee | last post by:
Hi, I have been looking at Themes and Skins today and now resonably understand how they work at a ground level. But I have a couple of questions. 1. ) StyleSheetTheme I dont understand...
1
by: matz2k | last post by:
I've got a big problem with the CSS layout which I've produced with Photoshop/Dreamweaver especially for my ebay auctions. This is what it looks like...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...

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.