 | |  |
 |

nigelparry.net
User
Sep 14, 2007, 12:50 PM
Post #1 of 2
(832 views)
Shortcut
|
|
Displaying fields in page titles on search results pages
|
Can't Post
|
|
Does anyone know how to use Java to display an LM field in page titles on search results pages? Here's the existing code we're working with to generate the in-page article titles. First script is in the header area, second is in the body area of the document. I guess what I'm asking is how to adapt these variables in Java, so that the HTML page title says: "LASIK Doctors in Arizona" (where Arizona is lfield35 in the script below). Any ideas? SCRIPT IN HEADER <script> var qsParm = new Array(); var query = window.location.search.substring(1); var parms = query.split('&'); for (var i=0; i<parms.length; i++) { var pos = parms[i].indexOf('='); if (pos > 0) { var key = parms[i].substring(0,pos); var val = parms[i].substring(pos+1); qsParm[key] = val; } } </script> SCRIPT IN BODY <script> var region = ""; if (qsParm['lfield35_keyword']) { var encoded = (qsParm['lfield35_keyword']); var pageTitle = unescape(encoded.replace(/\+/g, " ")); region = pageTitle; } if (region) { document.write ("<span class=\"article_title\">LASIK Doctors in " + region + "</span>"); } </script> [/code] _____________________ For more information about Nigel Parry and nigelparry.net websites please see http://nigelparry.net nigelparry.net: award-winning communications solutions for clients with something to say Website & print design Internet, public relations & media consulting
(This post was edited by nigelparry.net on Sep 14, 2007, 12:51 PM)
|
|
|  |
 |

MikeB
Staff
/ Moderator

Sep 15, 2007, 9:10 AM
Post #2 of 2
(818 views)
Shortcut
|
|
Re: [nigelparry.net] Displaying fields in page titles on search results pages
[In reply to]
|
Can't Post
|
|
Hi Nigel, Thanks for posting! I've taken a look at this for you and it looks like this should be something you can set up. You'll just want to make a quick change to the JavaScript that you're using and you'll want to modify the last part of the code that's in the body so it looks like this: if (region) { document.write ("<span class=\"article_title\">LASIK Doctors in " + region + "</span>"); document.title = "LASIK Doctors in " + region; } You'll notice that in addition to outputting a heading at the top of the page, this code will now set the title of the page to match the region value that was searched for. Give this a try and let me know how it works for you Nigel! Cheers, Mike Briggs - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 | |  |
|