javascript - Create dynamic url from user input -


i running blog: http://jokesofindia.blogspot.com. want provide dynamic link in sidebar of blog download hindi newspaper in pdf format.

i tried view source url of epaper.patrika.com , found if enter url epaper.patrika.com/pdf/get/145635/1 download first page , epaper.patrika.com/pdf/get/145635/2 download second page, , on.

the last part of url page number. second last part of url, '145635', changes every day. want able enter changing part of url manually every day , have javascript generate download links date replaced information entered.

this code needs work on mobile devices such android.

you can use html5 data object store data , use js data , append link:

html

<div class="linkholder" data-number="12345">     <a href="epaper.patrika.com/pdf/get/#/1">pdf page 1</a>     <a href="epaper.patrika.com/pdf/get/#/2">pdf page 2</a> </div> 

js

$(document).ready(function() {   var newnum = $('.linkholder').attr('data-number');   $('.linkholder a').each(function() {      var newlink = $(this).attr('href').replace('#', newnum);     $(this).attr('href',newlink);     }); }); 

view codepen see in action.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -