Author Topic: AJAX in <title> ?  (Read 3188 times)

0 Members and 1 Guest are viewing this topic.

Offline DaculaWeather

  • It's a Jeep thing... you wouldn't understand.
  • WxElement panel
  • Forecaster
  • *****
  • Posts: 3171
  • SCCA EM #156
    • North Georgia and US Weather
AJAX in <title> ?
« on: February 22, 2008, 08:11:12 AM »
I currently use the temp variable in the title of my website (which works great) but would love to use the AJAX temp variable. I've tried inserting the span section to the title but it displays along with the temp.

Any ideas?

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 6880
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: AJAX in <title> ?
« Reply #1 on: February 22, 2008, 10:59:46 AM »
Hi Steve,
I'm not certain that dynamic updates to HTML in the <head></head> section of the page are supported by browsers .. they tend to parse/act on that area of the page when it's first loaded, then not 'worry' about it until the full page is reloaded.

If you look at the HTML spec for <title> it's just bare-bones with none of the attributes available with a <span>, <div> or <p> tag.

So.. it's unlikely that dynamic changes to <title> will be work as you wish.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline DaculaWeather

  • It's a Jeep thing... you wouldn't understand.
  • WxElement panel
  • Forecaster
  • *****
  • Posts: 3171
  • SCCA EM #156
    • North Georgia and US Weather
Re: AJAX in <title> ?
« Reply #2 on: February 22, 2008, 03:41:45 PM »
That's  what I thought too. Thanks anyway!

Offline Anole

  • Forecaster
  • *****
  • Posts: 585
    • http://pineislandweather.com
Re: AJAX in <title> ?
« Reply #3 on: February 24, 2008, 05:36:01 AM »
What you could do is use some PHP code to generate your <title>.

Offline Anole

  • Forecaster
  • *****
  • Posts: 585
    • http://pineislandweather.com
Re: AJAX in <title> ?
« Reply #4 on: February 25, 2008, 08:31:57 AM »
I just implemented this on my main page using php:
http://weather.anolecomputer.com

I did it as follows:
Code: [Select]
// do an include to get your data. I'm using a script that pulls info from WD clientraw.
<? @include "/home/anolecom/public_html/weather/wxscripts/parseclientraw/parse_clientraw.php"; ?>
<title>St. James City, FL Weather: <?=$Temp;?>&deg;</title>


All of the above code is in the head section.

Offline up10ad

  • USA Weather Finder
  • WxElement panel
  • Forecaster
  • *****
  • Posts: 573
  • Station will be back up someday...
    • Forecaster without a site
Re: AJAX in <title> ?
« Reply #5 on: February 25, 2008, 09:06:56 AM »
For those using VWS there is also an easy way.  I think it has already been poseted elsewhere but here it is again. 

Create a .htx file in your VWS TEMPLATES directory named title.htx containing:

Code: [Select]
^vxv007^&deg; F Delta
Be sure to change Delta to your city name of station name, and you can add other tags if desired.  Then in VWS under Internet|HTML Settings add title.htx as the template name and title.txt as the HTML Filename.

In your documents then replace the title tag in the head section with: 

Code: [Select]
<title><?php include ("title.txt"); ?></title>
Rick (K6DYC)
Have you joined USAWeatherFinder.com yet?

Online jwwd

  • Senior Member
  • **
  • Posts: 59
    • Weather at Silkeborg, Denmark
Re: AJAX in <title> ?
« Reply #6 on: February 25, 2008, 10:10:06 AM »
I just implemented this on my main page using php:
http://weather.anolecomputer.com

I did it as follows:
Code: [Select]
// do an include to get your data. I'm using a script that pulls info from WD clientraw.
<? @include "/home/anolecom/public_html/weather/wxscripts/parseclientraw/parse_clientraw.php"; ?>
<title>St. James City, FL Weather: <?=$Temp;?>&deg;</title>


All of the above code is in the head section.

Hi Anole

What at great idea - i have it implemented on my website now.

www.buskelundtoften.dk/vejret/english

Thank you very much for the idea

Best regards,

Henrik

Davis Vantage Pro2 w/FARS & solarsensor. Boltek LD-250 Lightningdetector

Offline FourOhFour

  • Member
  • *
  • Posts: 15
    • skigod.us
Re: AJAX in <title> ?
« Reply #7 on: February 25, 2008, 10:11:17 AM »
You can edit the title of the page using javascript:
Code: [Select]
document.title = "new title goes here";

So you'd need to insert something like that into the function that updates all the data.