Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    New Coder
    Join Date
    Aug 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This code you have given me can go directly into the Wordpress HTML area of the page?

    ,,am I able to add the image banners I have created ie

    http://www.briantcomms.co.uk/wp-cont...e_Are_Open.jpg

    http://www.briantcomms.co.uk/wp-cont...ed_Banner1.jpg

    Rather than just having text 'Welcome to the store'? If so this is BRILLIANT thank you so much, I thought I would have to change the header.php but your way makes its so much easier.

    : )

  2. #17
    New Coder
    Join Date
    Aug 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can I add the image banners?

  3. #18
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Quote Originally Posted by m30ndo View Post
    Thanks for your help Philip, a user from this forum wrote the code for me, I have added it to the header.php was this the wrong thing to do?

    I apologise I am very new to coding, I tried simply adding this code to the page within Wordpress but this did not work : (
    Simply place the code in an external file (no HTML tags <script> and </script>) on the pages you want it to be active and call it right ahead of the </body> tag.

    <script src="myjsfile.js"></script>
    </body>


    I don't know anything about Wordpress but I have said you can easily replace the text messages by images.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  4. #19
    New Coder
    Join Date
    Aug 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thats great but how? Simply by pasting : http://www.briantcomms.co.uk/wp-cont...e_Are_Open.jpg

    Where the Welcome to the store text is ?

    Thanks again for you help.

  5. #20
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Awesome!!

    I have been searching for this for awhile now. I know this is an older thread but still has relevance. I am sure you have heard it a thousand times but I do not consider myself a coder by any stretch of the term. So here is my questions on the code as it refers to jmrker's post on 6/14/2012. I get how and where to change image refrences to my own and even adjusted the holidays I need and hours. Does this get saved as an external js file? or is it simply pasted before the </head> tag and then utilze <img id="logo" src="" alt=""> to place the image wherever on the page? Sorry if this is a n00b question

  6. #21
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,026
    Thanks
    36
    Thanked 494 Times in 488 Posts

    Lightbulb

    Quote Originally Posted by b0mbardo View Post
    I have been searching for this for awhile now. I know this is an older thread but still has relevance. I am sure you have heard it a thousand times but I do not consider myself a coder by any stretch of the term. So here is my questions on the code as it refers to jmrker's post on 6/14/2012. I get how and where to change image refrences to my own and even adjusted the holidays I need and hours. Does this get saved as an external js file? or is it simply pasted before the </head> tag and then utilze <img id="logo" src="" alt=""> to place the image wherever on the page? Sorry if this is a n00b question
    My assumption is that you are referring to this bit of code:
    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <title> Logo Script </title>
    <script type="text/javascript">
    // For: http://www.codingforums.com/showthread.php?p=1101084#post1101084
    
    var logos = [
    	'http://www.nova.edu/hpd/otm/pics/4fun/11.jpg',  // on-air image
    	'http://www.nova.edu/hpd/otm/pics/4fun/21.jpg',  // off-air image
    	'http://www.nova.edu/hpd/otm/pics/4fun/31.jpg'   // holidays image
    ]; 
    var holidays = ['1/1', '2/14', '3/17', '6/6',  '6/14',
    		'7/4','10/31','11/24','11/25','12/24','12/25'];
    
    onload = function () {
      var now = new Date();
      var DOW = now.getDay();
      var HH = now.getHours();
      if ( ((HH >= 8) && (HH < 18)) && ((DOW >= 1) && (DOW < 6)) ) {
        document.getElementById('logo').src = logos[0];
      } else {
        document.getElementById('logo').src = logos[1];
      }
      
      var tmp;
      for (var i=0; i<holidays.length; i++) {
    	tmp = new Date(holidays[i]+'/'+now.getFullYear());
    //	alert(tmp.toDateString()+'\n'+now.toDateString());  // for testing
    	if (tmp.toDateString() == now.toDateString()) {
          document.getElementById('logo').src = logos[2];
        }
      }
    }
    </script>
    
    </head>
    <body>
    <img id="logo" src="" alt="">
    </body>
    </html>
    The code as it is, is stand-alone. It should work if you save the file and call it with your browser as a file on you local computer or remote server.

    Can the JS be moved to an external file? Sure.
    Copy code between the <script> and </script> tags and paste it to an accessable location (usually same directory as program).
    Do not copy the <script> tags to the external file.
    Change the script reference to <script type="text/javascript" src="externalFileName.js"></script>

    If it still doesn't work, post the code you are using so we can see what you are doing differently.

    Good Luck!


 
Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •