0

I'm working with a client who's stuck using a widget based website and needs a custom built web app. We're hosting it off site. I need to pull product information from their main site to populate the off site page.

I wrote this to pull H1 content from their main site, this will serve as the link to the off site page.

<a href="#" id="specialURL">BUILD LEASE</a>

 <script type="text/javascript">
$(document).ready(function() {

  var url = $('h1').html();
  url = url.replace(/\s+/g, '-').toLowerCase()+'.html';


  console.log(url);
$('#specialURL').attr('href', 'http://joethemovie.com/' + url );



});

Now I need to turn the URL content back into an h1 on the off site page.

Also, if possible, does anyone know how I could store price information in the URL?

Such as http://example.com/mainSiteH1&price=12345

Then, same as the H1, display on the off site page.

Thanks!

1 Answers1

1

Anything you're sticking in a url should be uri encoded. this will take care of spaces too so the regex isn't necessary..

$('#specialURL').attr('href', 'http://joethemovie.com/?h1=' + encodeURIComponent(url) +"&price=" + encodeURIComponent("about tree fiddy"));

Then you can get that junk from the url using the server (php's $_GET for example), or you can use the function here to get those parameters with javascript..

Community
  • 1
  • 1
I wrestled a bear once.
  • 22,983
  • 19
  • 69
  • 116