Results 1 to 3 of 3

Thread: Help with Thinking Out Referrer-Based Info Swap

  1. #1
    Join Date
    Apr 2011

    Cool Help with Thinking Out Referrer-Based Info Swap

    Hi All,

    I was hoping to get some help with just figuring out how I should tackle an issue I'm having. I am pretty good with php and javascript, but no expert. Anyways, I have a site where I am wanting to swap some info around the Wordpress site, based on the referrer domain.

    More specifically, when a user comes from craigslist.org/anything/ , I need to be able to make a substitution of a couple of html elements during their session. Very likely I will be making that substitution through some combination of js and php - right? - but I'm not quite confident in how I should start off. The site in question is c.spinnakerapartments.com - I need to change the phone numbers on a particular category of posts, such as http://www.spinnakerapartments.com/p...innaker-brook/.

    If anyone just has any theories about how this should work, then PLEASE share them! And if you have a code snippet that might start work in this direction, that I can modify and play with, then PLEASE share that as well, it would be very helpful.


  2. #2
    Join Date
    Apr 2011
    Okay, I've been thinking this out. I've found two pieces of script below, and I think that if I can combine them, then they will actually do what I need them to do. However, the combining of javascripts is definitely not my strong-suit, so if anyone sees a good way to stick the two scripts below together, please help a brother out. Thank you.

    One - gets info to change on the page, selected by getElementById "phoner." Currently this snippet offers a direct input button to initiate the change of innerHTML -- so, I need that change to instead happen due to the referrer variable ...

    Two - this one makes a change occur due to a specific referrer - action/trigger of the javascript is the referrer variable. So, going back to One, above, the check on the referrer variable (here) would take the place of that input and onclick function (there) as the trigger...

    <script type="text/javascript">
    function changeText2(){
    	var userInput = document.getElementById('userInput').value;
    	document.getElementById('boldStuff2').innerHTML = userInput;
    <p>Welcome to the site <b id='boldStuff2'>dude</b> </p> 
    <input type='text' id='userInput' value='Enter Text Here' />
    <input type='button' onclick='changeText2()' value='Change Text'/>
    <!-- Hide script from old browsers
      if (document.referrer != 'craigslist.org')
    document.write('Thanks for visiting from ' + document.referrer);
    //-- Stop hiding script -->
    Thank you again for any help.

  3. #3
    Join Date
    Apr 2011
    Okay, I am getting this whittled down a little. The following code is sucessfully checking the referrer, of that I am sure - but I have something wrong in my syntax to do the innerHTML switch only when the correct referrer is matched. If anyone has any ideas, please let me know, hopefully I'm getting this code to a place where it makes a little more sense. Thanks!

    <script type="text/javascript">
     var hello = 'Hello World';
      if (document.referrer = 'http://plrdaily.net')
    document.getElementById('phoner').innerHTML = hello;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center