1

I would like to change the text on a page if the page is reached using a link with a particular class.

page 1

 <a class="button1" href="http://www.changetext.com">button 1</a>
 <a class="button2" href="http://www.changetext.com">button 2</a>

page 2 (changetext.com)

<p>Corporate Challenge fundraising goal</p>

If you reach changetext.com by selecting link with class "button2" then change every instance of the text "Corporate Challenge" to "Community Team"

Jenny
  • 781
  • 1
  • 9
  • 24
  • 2
    That is not possible. The target page does not get that information transmitted in any way, shape or form. If both pages are from the same domain, then you could transfer that information via cookie for example. – CBroe Nov 19 '15 at 14:27
  • 1
    The easiest way is to amend, and then read the url, otherwise you could set a cookie based on the class and amend content accordingly if the cookie exists – StudioTime Nov 19 '15 at 14:29

2 Answers2

2

This is not possible, without passing some parameter to the page

<a class="button1" href="http://www.changetext.com?button=1">button 1</a>
<a class="button2" href="http://www.changetext.com?button=2">button 2</a>

Now, in the targetted page, you can analyze the query string and do what you need with the value of the button variable

RiccardoC
  • 876
  • 5
  • 10
1

Well, using #hash is going to help you there.

That's what I mean:

<a class="button1" href="http://www.example.com">button 1</a>
<a class="button2" href="http://www.example.com/#btn2">button 2</a>

In your script on the second page:

$(document).ready(function(){
    if(location.hash=="#btn2"){
        $("p").each(function(){
            $(this).html($(this).html().replace(/Corporate Challenge/g,"Community Team"));
        });
    }
});
nicael
  • 18,550
  • 13
  • 57
  • 90