Help with Javascript snippet

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Oct 2009
Posts: 6
Reputation: Helban is an unknown quantity at this point 
Solved Threads: 0
Helban Helban is offline Offline
Newbie Poster

Help with Javascript snippet

 
0
  #1
Oct 29th, 2009
I would like to find a snippet of code to us in page using Javascript or JQuery. the function of the code is to make text appear weekly. Like random text or random image but I would like to control the text according to the week within the year ie. week 1 text 1, week 2 text2 etc. Can anyone help?
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 885
Reputation: Airshow will become famous soon enough Airshow will become famous soon enough 
Solved Threads: 127
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark
 
0
  #2
Oct 29th, 2009
Helban,

Try this :-
  1. function getWeekNo(startDay, baseDate){
  2. var now = new Date();
  3. startDay = (!startDay) ? 0 : startDay;//Default to Sunday
  4. baseDate = (!baseDate) ? new Date(now.getYear(), 0, 1) : baseDate;//Default to 1st Jan of current year.
  5. if(startDay !== -1){
  6. while(baseDate.getDay() !== startDay){ baseDate.setTime(baseDate.getTime() - (24 * 3600 * 1000)); }
  7. }
  8. return Math.ceil((now.getTime() - baseDate.getTime())/(7 * 24 * 3600 * 1000));
  9. }
As it depends on exactly what you mean by "week number", I have made the code flexible. The function accepts two parameters, as follows:
  • startDay : The day which should be used as the first day of each week. 0=Sunday, 1=Monday etc. Pass -1 to use the raw baseDate as week start, regardless of what day it is. Default = 0;
  • baseDate : The date to be used as the first day of the year. Default = 1st January of the current year.
Sample calls:
  1. var weekNo = getWeekNo();//Conventional week numbering based on calender year, each week starting on Sunaday.
  2. var weekNo = getWeekNo(1);//Conventional week numbering based on calender year, each week starting on Monday.
  3. showWeekNo( 6, new Date(new Date().getYear(), 3, 1) );//Week number of UK corporate fiscal year (1 April to 31 March), starting on Saturday (as used by some companies).
I've done some rudimtary testing and for some reason it waits untill 1:00 am on the first day of each week to throw a new week number, rather than the 00:00 (midnight) as you would expect. I can't immediately see why this should be. The rest of the time it seems to behave properly.

Please don't use my function in anything safety/financially/etc. critical.

For text, just set up an array of strings :-
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. var txtArray = [];
  2. txtArray[1] = 'On no, back to work, I\'m still a bit hung over';
  3. txtArray[2] = 'These dark nights are getting to me';
  4. txtArray[3] = 'Brrrr, had to scrape ice off my bicycle saddle this morning';
  5. txtArray[n] = 'xxxxxxx';
  6. txtArray[52] = 'Oh no, it\'s the Midwinter Retail Festival!';
  7. txtArray[53] = 'New year is upon us again';
Then index into this array with the week number returned by getWeekNo() . eg.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. weekMessage = txtArray[getWeekNo()];
Airshow
Last edited by Airshow; Oct 29th, 2009 at 7:28 pm.
50% of the solution lies in accurately describing the problem!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 6
Reputation: Helban is an unknown quantity at this point 
Solved Threads: 0
Helban Helban is offline Offline
Newbie Poster

Reply to Airshow - Thank you but more help please!

 
0
  #3
Oct 30th, 2009
Thank you so much for your code. I have not made it work successfully which could be due to my lack of javascript knowledge. Here is how I have embedded it within my page so far (txt Array reduced for this emai only), perhaps you could point you where I have gone wrong - many thanks:
  1. <SCRIPT language="Javascript"><!--
  2. function getWeekNo(startDay, baseDate){
  3. var now = new Date();
  4. startDay = (!startDay) ? 0 : startDay;//Default to Sunday
  5. baseDate = (!baseDate) ? new Date(now.getYear(), 0, 1) : baseDate;//Default to 1st Jan of current year.
  6. if(startDay !== -1){
  7. while(baseDate.getDay() !== startDay){ baseDate.setTime(baseDate.getTime() - (24 * 3600 * 1000)); }
  8. }
  9. return Math.ceil((now.getTime() - baseDate.getTime())/(7 * 24 * 3600 * 1000));
  10. }
  11. var txtArray=[53];
  12. txtArray[1]='On no, back to work, I\'m still a bit hung over';
  13. txtArray[2]='These dark nights are getting to me';
  14. txtArray[3]='Brrrr, had to scrape ice off my bicycle saddle this morning';
  15. txtArray[4]='Text week 4';
  16. txtArray[5]='Text week 5';
  17. txtArray[6]='Text week 6';
  18. txtArray[7]='Text week 7';
  19. txtArray[n]='Text week n;
  20. txtArray[37]='Text week 37';
  21. txtArray[38]='Text week 38';
  22. txtArray[39]='Text week 39';
  23. txtArray[40]='Text week 40';
  24. txtArray[41]='Text week 41';
  25. txtArray[42]='Text week 42';
  26. txtArray[43]='Text week 43';
  27. txtArray[44]='Text week 44';
  28. txtArray[45]='Text week 45';
  29. txtArray[46]='Text week 46';
  30. txtArray[47]='Text week 47';
  31. txtArray[48]='Text week 48';
  32. txtArray[49]='Text week 49';
  33. txtArray[50]='Text week 50';
  34. txtArray[51]='Text week 51';
  35. txtArray[52]='Oh no, it\'s the Midwinter Retail Festival!';
  36. txtArray[53]='New year is upon us again';
  37.  
  38. var weekMessage=txtArray[getWeekNo()]
  39. document.write(weekMessage + ' ');
  40. //-->
  41. </SCRIPT>
Last edited by peter_budo; Oct 31st, 2009 at 12:56 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 885
Reputation: Airshow will become famous soon enough Airshow will become famous soon enough 
Solved Threads: 127
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark
 
0
  #4
Oct 30th, 2009
Helban, you're nearly there.

First get rid of my line txtArray[n]='Text week n; , which is just pseudo-code.

It's better not to use document.write if you can avoid it. Do it this way instead :-

  1. <body>
  2. <div id="divExample"></div>
  3. <p>******* <span id="spanExample"></span> *******.</p>
  4. </body>
  1. onload = function(){
  2. var weekMessage = txtArray[getWeekNo()];
  3. var ex_1 = document.getElementById('divExample');
  4. var ex_2 = document.getElementById('spanExample');
  5. if(ex_1){ ex_1.innerHTML = weekMessage; }
  6. if(ex_2){ ex_2.innerHTML = weekMessage; }
  7. }
This allows the HTML to load quickly so the browser can start to render it. Javascript functions then follow on and fill in the gaps. It takes a bit of getting used to but you'll grow to love it.

The code above creates an anonymous function that fires when the page has loaded. It sniffs out two elements in your html then pokes weekMessage into them.

This is just an example to show that you can poke data into both block-elements (div in this case) and inline-elements (span in this case). You will do just one of these and give the chosen html element an id that reflects its purpose (eg id="weekMessage" ).

Airshow
Last edited by Airshow; Oct 30th, 2009 at 6:12 pm.
50% of the solution lies in accurately describing the problem!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 6
Reputation: Helban is an unknown quantity at this point 
Solved Threads: 0
Helban Helban is offline Offline
Newbie Poster

You can gone too fast for me, sorry cant understand your instructions.

 
0
  #5
Oct 31st, 2009
Hi Airshow, you have amazing patience with a novice.

Unfortunately, although I am sure it is superb, I cant follow what you said. I already have a body onload on that page so dont know if I can do two. Also although you have written snippets for me I am still not sure how to implement them with the page. For instance, I am not sure what the Span class is supposed to contain. I am also not sure where I would put the 'script Javascript' bit of the code. Is there a way of showing me a complete example within a dummy page and then I can copy it.

By the way the txtArray [n] was just to shortcut in the post and I have used the full 53 in the test I did.

Many thanks Airshow

Regards
Helban
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 885
Reputation: Airshow will become famous soon enough Airshow will become famous soon enough 
Solved Threads: 127
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark
 
1
  #6
Oct 31st, 2009
Originally Posted by Helban
I already have a body onload on that page so dont know if I can do two.
You can add the lines of code from my onload function above or below the lines within your existing onload function.
For example:
  1. onload = function(){
  2. //existing lines of code
  3. //existing lines of code
  4. //existing lines of code
  5. var weekMessage = txtArray[getWeekNo()];
  6. var ex_1 = document.getElementById('divExample');
  7. var ex_2 = document.getElementById('spanExample');
  8. if(ex_1){ ex_1.innerHTML = weekMessage; }
  9. if(ex_2){ ex_2.innerHTML = weekMessage; }
  10. }
Typically it will not matter whether you add above or below, but you have to be careful in case one block of code affects or is dependant on the other.

Originally Posted by Helban
For instance, I am not sure what the Span class is supposed to contain.
SPAN is just a general purpose HTML inline element, in the same way that DIV is a general purpose HTML block element. SPAN can be used to style a portion of a string, or (as we want here) to allow us to address it in javascript. You can read more about div and span here.

Originally Posted by Helban
I am also not sure where I would put the 'script Javascript' bit of the code.
In a well modern, written web page, all javascript will be in the document's HEAD. You will find many web pages in which javascript appears in the document's BODY however, without exception, anything that needs to be performed in javascript can be performed by code in the HEAD with the BODY free to contain (X)HTML (or other markup language).

Originally Posted by Helban
Is there a way of showing me a complete example within a dummy page and then I can copy it.
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html>
  4. <head>
  5. <title>Airshow :: Week Number Calculation</title>
  6.  
  7. <style type="text/css">
  8. body { font-family:verdana,helvetica,sans-serif; font-size:10pt; }
  9. #weekMessageContainer { width:200px; border:1px solid #006699; }
  10. #weekMessageContainer h1 { margin:0; padding:10px 0; background-color:#006699; color:white; font-size:12pt; text-align:center; }
  11. #divExample { padding:5px; text-align:center; }
  12. #weekMessage { font-size:11pt; }
  13. #spanExample { color:#006699; text-decoration:underline; }
  14. </style>
  15.  
  16. <script>
  17. var txtArray = [];
  18. for(var i=1; i<=53; i++){
  19. txtArray[i] = "This is Week No. " + i;
  20. }
  21. function getWeekNo(startDay, baseDate){
  22. var now = new Date();
  23. startDay = (!startDay) ? 0 : ParseInt(startDay);//Default to Sunday
  24. baseDate = (!baseDate || baseDate.constructor !== Date) ? new Date(now.getYear(), 0, 1) : baseDate;//Default to 1st Jan of current year.
  25. if(startDay !== -1){
  26. while(baseDate.getDay() !== startDay){ baseDate.setTime(baseDate.getTime() - (24 * 3600 * 1000)); }
  27. }
  28. return Math.ceil((now.getTime() - baseDate.getTime())/(7 * 24 * 3600 * 1000));
  29. }
  30.  
  31. onload = function(){
  32. var weekMessage = txtArray[getWeekNo()];
  33. var ex_1 = document.getElementById('divExample');
  34. var ex_2 = document.getElementById('spanExample');
  35. if(ex_1){ ex_1.innerHTML = weekMessage; }
  36. if(ex_2){ ex_2.innerHTML = weekMessage; }
  37. }
  38. </script>
  39. </head>
  40.  
  41. <body>
  42.  
  43. <div id="weekMessageContainer">
  44. <h1>Div Example</h1>
  45. <div id="divExample"></div>
  46. </div>
  47.  
  48. <p id="weekMessage">Span example: <span id="spanExample"></span>.</p>
  49.  
  50. </body>
  51. </html>
Originally Posted by Helban
By the way the txtArray [n] was just to shortcut in the post and I have used the full 53 in the test I did.
Understood.
You will see above that I have done something slightly different. The array is populated in a loop (for the purpose of the demonstration).

Airshow
50% of the solution lies in accurately describing the problem!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 6
Reputation: Helban is an unknown quantity at this point 
Solved Threads: 0
Helban Helban is offline Offline
Newbie Poster
 
0
  #7
34 Days Ago
Dear Airshow

I wanted to thank you for your help a couple of weeks ago with Javascript. Unfortunately I got the week message to work with the last instructions but using it with onload threw out all my other javascript and code including a keyword search so could not risk using it.

I think if I had stuck to the first stages and got them in the right order it might have been ok. It was a good idea for the site I am making but beyond me to install it. I think you have alot of patience.

Thank you all the same.
Helban
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 885
Reputation: Airshow will become famous soon enough Airshow will become famous soon enough 
Solved Threads: 127
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark
 
0
  #8
34 Days Ago
Helban,

If you want, post a whole page here and I will try to understand what's going wrong for you. It's probably something simple.

Airshow
50% of the solution lies in accurately describing the problem!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 6
Reputation: Helban is an unknown quantity at this point 
Solved Threads: 0
Helban Helban is offline Offline
Newbie Poster

Here goes Airshow:

 
0
  #9
29 Days Ago
This is my page. You will see I already have some Javascript and an onload instruction for a keywords search (php). It is the keyword search that is thrown out if I add another onload instruction.

If you can help with not too much effort I would be very grateful.

Many thanks
Helban

[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/homepage_temp.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Shalom Ministries information site for Jewish people explaining that Jesus is the Messiah, with stories by Jews and rabbis"/>
<meta name="keywords" content="Jews, Jewish, Judaism, Outreach, Israel, Torah, Talmud, Sidra, Rabbis, Messiah, Messianic, Shalom, Peace, Religion, Missionary, Gospel, Bible"/>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Shalom Ministries, Home Page</title>
<!-- InstanceEndEditable -->
<link href="styles/SMpagestyle.css" rel="stylesheet" type="text/css" />
<link href="styles/SMnavstyles.css" rel="stylesheet" type="text/css" />
<link href="styles/SMsearchstyles.css" rel="stylesheet" type="text/css" />

<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->

</head>

<body onload="if (document.getElementById('zoom_searchbox')) {document.getElementById('zoom_searchbox').focus();}" >
<a name="top" id="top"></a>

<div id="container">
<div id="banner"></div>

<div id="datetabs">
<div id="datebox"><script language="JavaScript1.2" type="text/javascript">
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000)
year = year + 1900;
document.write(date + " ");
document.write(lmonth + " " + year);
// End --></script></div>
<!--ZOOMSTOP-->

<div id="tabtop1">
<div id="tabbox"><a href="index.html">Home</a></div>
<div id="tabbox"><a href="content/contactus.html">Contact</a></div>
<div id="tabbox"> <a href="shop/books.html">Shop</a></div>
</div>
<!-- InstanceBeginEditable name="Noentry1" --> <!-- InstanceEndEditable -->
<!--ZOOMRESTART--></div>
<div id="mainpage">
<div id="searchmaincont">
<div id="searchcont"> <div id="wordsearchbox"><form action="http://www.shalom.org.uk/newsite/search/search.php" method="GET"><span class="keywordleft">Keyword:</span><input type="text" name="zoom_query" class="input1" /><input type="submit" name="zoom_button" class="button2" value="Search" alt="Go" /></form></div>
</div>
</div>
<div id="leftcol"><!--ZOOMSTOP-->
<div id="navcont">
<div id="nav">
<ul>
<li> <a href="content/news.html">News</a></li>
<li> <a href="content/events.html">Events</a></li>
<li> <a href="library/library.html">Library</a></li>
<li> <a href="content/downloads.html">Downloads</a></li>
<li> <a href="content/relatedsites.html">Related Sites</a></li>
</ul>
</div>
<!-- InstanceBeginEditable name="Noentry2" --><!-- InstanceEndEditable -->
</div><!--ZOOMRESTART-->
</div>
<div id="rightcol"><!-- InstanceBeginEditable name="pagetext" -->
<div id="pagetext">
<h6>Welcome to the website of Shalom Ministries </h6>
<p>We are a group of Jews and Gentiles who have come to believe that Jesus of Nazareth is the Messiah of Israel and Saviour of the world. Through Jesus, or Yeshua, we enjoy the blessings of the New Covenant that God promised to the house of Israel and the house of Judah. Through him, God's Torah has been written on our hearts, our sins have been forgiven and we know the God of Avraham, Yitzak and Ya'acov as our God and Father.
</p>
<p>We welcome your comments and interaction.</p>
<p>&nbsp;</p>
<h1>Light from the Sidra</h1>
<p>&nbsp;</p>
<p>Weekly text to go here.........</p>


</div>

<!-- InstanceEndEditable --></div>
<div id="clearpage"> </div>
<!--ZOOMSTOP--><div id="backtonav"> <!-- InstanceBeginEditable name="backtonav" -->
<div id="backtop"><span class="arrow">&and;</span> <a href="#top"> Back to top</a></div>

<!-- InstanceEndEditable --></div>
<div id="clearpage"> </div>
<br /><!--ZOOMRESTART-->
</div>

<!--ZOOMSTOP--><div id="bottombar">
&copy; <script language="JavaScript1.2" type="text/javascript">
var year=time.getYear();
if (year < 2000)
year = year + 1900;
document.write(" " + year);
// End --></script>
Shalom Ministries&nbsp;&nbsp; <span class="title">•</span> &nbsp;&nbsp;<a href="mailto:email: comms@shalom.org.uk?subject=Query from www.shalom.org.uk">email: comms@shalom.org.uk</a> &nbsp;&nbsp; <span class="title">•</span> &nbsp;&nbsp;<a href="content/sitemap.html">site map</a><br />
We do not necessarily endorse the contents of this site.
</div><!--ZOOMRESTART-->

</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-10982662-2");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
<!-- InstanceEnd --></html>]
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 885
Reputation: Airshow will become famous soon enough Airshow will become famous soon enough 
Solved Threads: 127
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark
 
0
  #10
28 Days Ago
Helban,

Try this :
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/homepage_temp.dwt" codeOutsideHTMLIsLocked="false" -->
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="description" content="Shalom Ministries information site for Jewish people explaining that Jesus is the Messiah, with stories by Jews and rabbis"/>
  7. <meta name="keywords" content="Jews, Jewish, Judaism, Outreach, Israel, Torah, Talmud, Sidra, Rabbis, Messiah, Messianic, Shalom, Peace, Religion, Missionary, Gospel, Bible"/>
  8. <!-- InstanceBeginEditable name="doctitle" -->
  9. <title>Shalom Ministries, Home Page</title>
  10. <!-- InstanceEndEditable -->
  11. <style>
  12. ul.inline {
  13. list-style-type: none;
  14. margin:0;
  15. padding:0;
  16. font-size:9pt;
  17. }
  18. ul.inline li {
  19. display: inline;
  20. padding: 0 9px;
  21. border-left: 1px solid #333;
  22. }
  23. ul.inline li.first {
  24. padding-left: 0;
  25. border-left-width: 0;
  26. }
  27. </style>
  28. <link href="styles/SMpagestyle.css" rel="stylesheet" type="text/css" />
  29. <link href="styles/SMnavstyles.css" rel="stylesheet" type="text/css" />
  30. <link href="styles/SMsearchstyles.css" rel="stylesheet" type="text/css" />
  31. <!-- InstanceBeginEditable name="head" -->
  32. <!-- InstanceEndEditable -->
  33. <script language="JavaScript1.2" type="text/javascript">
  34. onload = function(){
  35. var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  36. var time = new Date();
  37. year = (time.getYear() < 2000) ? (time.getYear() + 1900) : time.getYear();
  38. var el = document.getElementById('date');
  39. if(el){ el.innerHTML = time.getDate() + " " + months[time.getMonth() + 1] + " " + year; }
  40. var el2 = document.getElementById('c_year');
  41. if(el2){ el2.innerHTML = year; }
  42. var el3 = document.getElementById('zoom_searchbox');
  43. if(el3){ el3.focus(); }
  44.  
  45. var getWeekNo = function(startDay, baseDate){
  46. var now = new Date();
  47. startDay = (!startDay) ? 0 : startDay;//Default to Sunday
  48. baseDate = (!baseDate) ? new Date(now.getYear(), 0, 1) : baseDate;//Default to 1st Jan of current year.
  49. if(startDay !== -1){
  50. while(baseDate.getDay() !== startDay){ baseDate.setTime(baseDate.getTime() - (24 * 3600 * 1000)); }
  51. }
  52. return Math.ceil((now.getTime() - baseDate.getTime())/(7 * 24 * 3600 * 1000));
  53. };
  54. var txtArray = [];
  55. // ******* Replacve this line to provide one message per week (hard coded). *******
  56. for(var i=0; i<53; i++){ txtArray.push('This is week number ' + i); }
  57. // ******* **************************************************************** *******
  58. var el4 = document.getElementById('weekMessage');
  59. if(el4) { el4.innerHTML = txtArray[getWeekNo()]; }
  60. }
  61. </script>
  62. </head>
  63.  
  64. <body>
  65. <a name="top" id="top"></a>
  66. <div id="container">
  67. <div id="banner"></div>
  68. <div id="datetabs">
  69. <div id="datebox"><span id="date"></span></div>
  70. <!--ZOOMSTOP-->
  71. <div id="tabtop1">
  72. <div id="tabbox"><a href="index.html">Home</a></div>
  73. <div id="tabbox"><a href="content/contactus.html">Contact</a></div>
  74. <div id="tabbox"> <a href="shop/books.html">Shop</a></div>
  75. </div>
  76. <!-- InstanceBeginEditable name="Noentry1" --> <!-- InstanceEndEditable -->
  77. <!--ZOOMRESTART--></div>
  78. <div id="mainpage">
  79. <div id="searchmaincont">
  80. <div id="searchcont">
  81. <div id="wordsearchbox"><form action="http://www.shalom.org.uk/newsite/search/search.php" method="GET"><span class="keywordleft">Keyword:</span><input type="text" name="zoom_query" class="input1" /><input type="submit" name="zoom_button" class="button2" value="Search" alt="Go" /></form></div>
  82. </div>
  83. </div>
  84. <div id="leftcol"><!--ZOOMSTOP-->
  85. <div id="navcont">
  86. <div id="nav">
  87. <ul>
  88. <li><a href="content/news.html">News</a></li>
  89. <li><a href="content/events.html">Events</a></li>
  90. <li><a href="library/library.html">Library</a></li>
  91. <li><a href="content/downloads.html">Downloads</a></li>
  92. <li><a href="content/relatedsites.html">Related Sites</a></li>
  93. </ul>
  94. </div>
  95. <!-- InstanceBeginEditable name="Noentry2" --><!-- InstanceEndEditable -->
  96. </div><!--ZOOMRESTART-->
  97. </div>
  98. <div id="rightcol"><!-- InstanceBeginEditable name="pagetext" -->
  99. <div id="pagetext">
  100. <h6>Welcome to the website of Shalom Ministries </h6>
  101. <p>We are a group of Jews and Gentiles who have come to believe that Jesus of Nazareth is the Messiah of Israel and Saviour of the world. Through Jesus, or Yeshua, we enjoy the blessings of the New Covenant that God promised to the house of Israel and the house of Judah. Through him, God's Torah has been written on our hearts, our sins have been forgiven and we know the God of Avraham, Yitzak and Ya'acov as our God and Father.</p>
  102. <p>We welcome your comments and interaction.</p>
  103. <h1>Light from the Sidra</h1>
  104. <p>Message of the week : <span id="weekMessage"></span></p>
  105. </div>
  106. <!-- InstanceEndEditable --></div>
  107. <div id="clearpage"> </div>
  108. <!--ZOOMSTOP--><div id="backtonav"> <!-- InstanceBeginEditable name="backtonav" -->
  109. <div id="backtop"><span class="arrow">&and;</span>&nbsp;<a href="#top">Back to top</a></div>
  110. <!-- InstanceEndEditable --></div>
  111. <div id="clearpage"> </div>
  112. <!--ZOOMRESTART-->
  113. </div>
  114. <!--ZOOMSTOP--><div id="bottombar" style="margin-top:1.5em;">
  115. <ul class="inline">
  116. <li class="first">&copy;&nbsp;<span id="c_year"></span>&nbsp;Shalom Ministries</li>
  117. <li><a href="mailto:comms@shalom.org.uk?subject=Query from www.shalom.org.uk">email: comms@shalom.org.uk</a></li>
  118. <li><a href="content/sitemap.html">site map</a></li>
  119. </ul>
  120. We do not necessarily endorse the contents of this site.
  121. </div><!--ZOOMRESTART-->
  122. </div>
  123. <script type="text/javascript">
  124. var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  125. document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  126. try {
  127. var pageTracker = _gat._getTracker("UA-10982662-2");
  128. pageTracker._trackPageview();
  129. }
  130. catch(err) {}
  131. </script>
  132. </body><!-- InstanceEnd -->
  133. </html>
As you will see, I have installed your weekly text and otherwise tidied the page up quite a lot. In particualr :
  • Moved most of the embedded javascript out of the html and put it in the header (in a function that will run when the page has loaded).
  • Purged all <br>s as a means of controlling vertical spacing (almost nothing drives me more nuts!)
  • Converted a rather messy "bottombar" to a nice clean inline list (with a handful of css directives in the head).
You can style up the weekly message as you wish in css and can adopt as many of my ideas or discard as you see fit.

Hope it helps.

Airshow
50% of the solution lies in accurately describing the problem!
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 1059 | Replies: 12
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC