javascript - Targeting URL content and displaying on page -


i'm working client who's stuck using widget based website , needs custom built web app. we're hosting off site. need pull product information main site populate off site page.

i wrote pull h1 content main site, serve link 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 need turn url content h1 on off site page.

also, if possible, know how store price information in url?

such http://example.com/mainsiteh1&price=12345

then, same h1, display on off site page.

thanks!

anything you're sticking in url should uri encoded. take care of spaces regex isn't necessary..

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

then can junk url using server (php's $_get example), or can use function here parameters javascript..


Comments