Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 78

AccessYou
Lost but trying
Profile
Posts: 3
Reg: Aug 25, 2013
Rotorua
3,580
09/15/13 03:26 AM (12 years ago)

How do I create a redirect to a dynamic url using the date?

Hi I am wanting my app to display an image from a url which will change each day. To avoid having to change the image every day I plan to set up 12 folders each with 28 - 31 images in (depending on the month number)and would like my app to display the image for that day depending on the date so the url for the image today would be http://www.fakeurl.com/9/15.jpg. I have written the code below and the var generates the right url (checked using the doument.write) but can you help me with why it is not displaying the image? What have I missed or where have i gone wrong? Thanks Heaps!! <script> var tD = new Date(); var datestr = "http://www.fakeurl.com/" + (tD.getMonth("MM")+1) + "/" + tD.getDate() + ".jpg"; document.write(datestr); </script> <meta http-equiv="refresh" content="0; url=datestr;>
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
09/15/13 05:34 AM (12 years ago)
I have a couple of scripts over at BTMods you can probably snoop through and get what you want. https://www.buzztouchmods.com/downloads.php?cat_id=2&download_id=54 https://www.buzztouchmods.com/downloads.php?cat_id=2&download_id=53 Let me know if you have specific questions later. Cheers! -- Smug
 
Cakebit
Code is Art
Profile
Posts: 502
Reg: Dec 15, 2010
In your local b...
16,520
like
09/15/13 08:08 AM (12 years ago)
@AccessYou, Try this peice of code: <script> var tD = new Date(); var datestr = "http://www.fakeurl.com/" + (tD.getMonth("MM")+1) + "/" + tD.getDate() + ".jpg"; document.write(datestr); window.location = datestr </script> It works perfectly for me! In general it is better to stick to only one language since the code is compiled by the app browser.
 
AccessYou
Lost but trying
Profile
Posts: 3
Reg: Aug 25, 2013
Rotorua
3,580
like
09/15/13 02:31 PM (12 years ago)
@CakeBit I LOVE YOU YOU ROCK!!!!!! Thank you thank you thank you. I am very much an amature at coding and am so so grateful. @SmugWimp Thank you for your contribution. I tried CakeBit's first and it worked perfectly so havent had a look through yours. Very grateful you took the time to answer me!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
09/15/13 06:50 PM (12 years ago)
The bottom line is getting a solution! Glad you're back in business. CakeBit did a nice little edit; I'm sneaking it into my snippets :) Cheers! -- Smug
 
Cakebit
Code is Art
Profile
Posts: 502
Reg: Dec 15, 2010
In your local b...
16,520
like
09/15/13 07:11 PM (12 years ago)
Glad to help lads!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.