LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-07-2005, 09:12 PM   #1
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Rep: Reputation: 30
Question Time determines home page


This might be more of a Firefox question than a Linux software question, but I thought I'd give it a shot here since the answer would probably involve more than Firefox itself. Is there a way to make your home page change depending on the time of day?
 
Old 09-07-2005, 09:57 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
You could probably create a cron job to edit your firefox configuration file. It's just javascript.
 
Old 09-07-2005, 10:11 PM   #3
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Original Poster
Rep: Reputation: 30
That makes sense, although I use a laptop and it's not always on, so that would throw off the jobs. What would be the best way to handle it? I guess I could do a cron job every few minutes to check, but that doesn't seem to be the most efficient. Any other ideas, or should I just try to do something like that?
 
Old 09-07-2005, 10:14 PM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
You could add an @reboot cron job to test the current time and set it to what the page should be then.
 
Old 09-07-2005, 10:29 PM   #5
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Original Poster
Rep: Reputation: 30
That'll work, thanks. One more thing... since I'm not too familiar with bash scripting could someone post a quick example that would test the time and, under various periods, change the address field in:

user_pref("browser.startup.homepage", "www.google.com");

I'll go do the google work and figure it out, but if someone could give me a start on the structure of the cases and changing the file that would be much appreciated.
 
Old 09-07-2005, 10:36 PM   #6
tomj88
Member
 
Registered: Apr 2005
Location: Wolverhampton, England
Distribution: Ubuntu
Posts: 334

Rep: Reputation: 30
You could use javascript directly in the browser to display different content depending on the time of day.. I will try and find something for you...
 
Old 09-07-2005, 10:38 PM   #7
tomj88
Member
 
Registered: Apr 2005
Location: Wolverhampton, England
Distribution: Ubuntu
Posts: 334

Rep: Reputation: 30
http://webmonkey.wired.com/webmonkey...user_interface
This changes the background depending on the day of the week, you could try to modify that to your needs.
 
Old 09-07-2005, 10:43 PM   #8
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Original Poster
Rep: Reputation: 30
I'm not sure I know enough about Javascript either to change that from days to time and set up the cases. Are you saying forget about cron jobs and bash scripts and actually put it as Javascript in the user.js file? Would that get run every time Firefox opened?
 
Old 09-08-2005, 09:26 AM   #9
tomj88
Member
 
Registered: Apr 2005
Location: Wolverhampton, England
Distribution: Ubuntu
Posts: 334

Rep: Reputation: 30
not even in a .js file, you could run the javascript inline within the .html file (or .htm, .php etc). Javascript is interpreted by the browser, so it is run everytime the document is (down)loaded. You would not need a cron task to change the script, because the javascript would only show the wanted page. It would also be possible to do this in php. With Javascript, if the user clicked view source, then he would be able to see the other page's html. With php, because it is processed server side, the user would only see the html that you specify for that time. It would be quite easy in php. I'm not sure whether this would work but here goes!

PHP Code:
<?php
$the_time 
date('a'); 
# Lowercase Ante meridiem and Post meridiem
# am or pm

if ($the_time == 'am') {
  include(
'morning.html'); # replace morning.html with the page for the morning
} else {
  include(
'afternoon.html'); # replace afternoon.html with the page for the afternoon
}
?>
As reference, you may need/want to look here for details on the php date() function. Here, the script is detecting whether it is morning (am) or afternoon (pm). Another way to do it would be to display the page imbetween 10am and 6pm, and any time after that display another page.
PHP Code:
<?php
$the_time 
date('H'); 
# 24-hour format of an hour with leading zeros
# 00 through 23

if ($the_time <= 10) {
  if (!
$the_time >= 18) {
    include(
'page1.html'); # replace as neccessary
  
} else {
    include(
'page2.html'); # replace as neccessary
  
}
} else {
  include(
'page2.html');
}
?>
There is probably a far better way of doing this... To get this to work, you will need a httpd server such as apache with php support...

Last edited by tomj88; 09-08-2005 at 09:27 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
lost start page (home page?) multiplaone Linux - Newbie 1 05-29-2005 06:10 PM
Konqueror and Home Page? Dmacnumberfour Linux - Software 2 07-06-2004 09:08 PM
konqueror home page ronss Linux - Distributions 0 05-20-2004 07:24 AM
yahoo home page sfcror Linux - Software 0 10-07-2003 07:07 PM
Konqueror Home Page? cabrone Linux - Newbie 7 09-15-2003 06:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration