Yogender Posted September 2, 2015 Share Posted September 2, 2015 Ok...the scene is I have prepared a intranet website for my company & on homepage all employees birthday information is mentioned for coming month only. My requirement is when a user opens the intranet page & if on that day anyone is having his/her birthday...a pop msg should come saying "Today is XXX birthday".... Is it possible?? Every month 2-8 employees are having their b'days... Pls help if you understand the requirement. Link to comment Share on other sites More sharing options...
Ingolme Posted September 2, 2015 Share Posted September 2, 2015 Not with Javascript. You would need the birth dates stored on a server and have a server-side language retrieve them. Link to comment Share on other sites More sharing options...
davej Posted September 2, 2015 Share Posted September 2, 2015 Yes you could do that with Javascript, but then the file containing all the birthdays could also be downloaded by anyone who can see the page. Link to comment Share on other sites More sharing options...
Yogender Posted September 4, 2015 Author Share Posted September 4, 2015 Hi Davej.....I don't have any issue with that..pls tell the way..... Link to comment Share on other sites More sharing options...
davej Posted September 4, 2015 Share Posted September 4, 2015 Try... <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><title>title</title><style></style><script>window.onerror = function(a,b,c,d){alert('Javascript Error: '+a+'nURL: '+b+'nLine Number: '+c+' Col Number: '+d);return true;}</script><script>'use strict';window.onload = init;var bdays = [ 'Eleanor Clift', 9,5,'Pat Buchanan', 9,14,'Mort Zuckerman', 9,14,'Clarence Page', 9,5,'Monica Crowley', 9,5,'John McLaughlin', 9,14];function init() {var d = new Date();var month = d.getMonth() + 1;var day = d.getDate();var str = '';//alert('Today is ' + month + '/' + day);for (var i=0, len=bdays.length ; i<len ; i+=3){ if (bdays[i+1] == month && bdays[i+2] == day){ str += '<h2>' + bdays[i] + '</h2>'; }}if (str.length == 0){ str = '<h2>Sorry, no birthdays today.</h2>';}else{ str = '<h1>Today's Birthdays:</h1>' + str;}document.getElementById('out1').innerHTML = str;}// end func</script></head><body><div id="out1"></div></body> </html> 1 Link to comment Share on other sites More sharing options...
Yogender Posted September 5, 2015 Author Share Posted September 5, 2015 Thank you davej..... One more help if you can.....how to turn it to welcome & pop up msg... Link to comment Share on other sites More sharing options...
davej Posted September 5, 2015 Share Posted September 5, 2015 Well, this is one popup approach... <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><title>title</title><style>.hidden{display:none;}.popup{display:block;margin:0 auto;width:300px;background-color:#fb0;border:3px solid #000;border-radius:10px;text-align:center;cursor:pointer;}#overlay{position:fixed;top:40px;left:0;right:0;}</style><script>window.onerror = function(a,b,c,d){alert('Javascript Error: '+a+'nURL: '+b+'nLine Number: '+c+' Col Number: '+d);return true;}</script><script>'use strict';window.onload = init;var bdays = [ 'Eleanor Clift', 9,6,'Pat Buchanan', 9,4,'Mort Zuckerman', 9,5,'Clarence Page', 9,6,'Monica Crowley', 9,5,'John McLaughlin', 9,6];function init() {var d = new Date();var month = d.getMonth() + 1;var day = d.getDate();var str = '';//alert('Today is ' + month + '/' + day);for (var i=0, len=bdays.length ; i<len ; i+=3){ if (bdays[i+1] == month && bdays[i+2] == day){ str += '<h2>' + bdays[i] + '</h2>'; }}if (str.length == 0){ str = '<h2>Sorry, no birthdays today.</h2>';}else{ str = '<div style="text-align:right;margin:0 5px 0 0">X</div><h1>Today's Birthdays:</h1>' + str;}var p = document.getElementById('out1');p.innerHTML = str;p.onclick = hidepop;setTimeout(popup,3000);}// end funcfunction popup(){document.getElementById('out1').className = 'popup';}function hidepop(){document.getElementById('out1').className = 'hidden';}</script></head><body><p>aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn ooo ppp qqq rrr sss ttt uuu rrr sss ttt uuu vvv www xxxyyy zzz aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn ooo ppp qqq rrr sss ttt uuu rrr sss ttt uuu vvv www xxxyyy zzz aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn ooo ppp qqq rrr sss ttt uuu rrr sss ttt uuu vvv www xxxyyy zzz aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn ooo ppp qqq rrr sss ttt uuu rrr sss ttt uuu vvv www xxxyyy zzz aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn ooo ppp qqq rrr sss ttt uuu rrr sss ttt uuu vvv www xxxyyy zzz</p><div id="overlay"> <div id="out1" class="hidden"> </div></div></body> </html> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now