473,414 Members | 1,627 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Change URLs in search results

I have a small challenge and you'll have to excuse me because I haven’t touched JS for some time and have gotten a bit rusty.

I have an intranet site at work that has roughly 500,000 htm pages (no joke). I have a search engine (zoom) that returns results of the various htm files. The site that I indexed is setup with about 41,600 folders with each folder containing 12 to 13 htm files. One of the htm files is a default.htm file that is actually a frame page that displays the other htm files. When I ran zoom to index the site it did not index the default.htm pages in each folder because there is no text in it.

My users need to always see the default.htm page rather than being able to select the other pages from the search engine.

So what I want to do is put a JavaScript on the search results page that looks at the various URLs and changes the URL OnClick to "default.htm" if it finds one of the htm pages in the URL.

The htm files to change are as follows:

doc_index.htm
document_history.htm
frame_menu.htm
project_history.htm
status.htm
status_history.htm
summary.htm
task_history.htm
task_list.htm
terms.htm
terms_history.htm

Is there a quick and easy way to do this?

Thanks in advance for any help.
Apr 3 '08 #1
2 1627
hsriat
1,654 Expert 1GB
In your search page, you might be using <a> to link to each search result.
In each <a> tag, add onclick="return goToDefault(this);"

And the JS is...
Expand|Select|Wrap|Line Numbers
  1. function goToDefault(link) {
  2.     arr = link.href.split('/');
  3.     arr[arr.length-1] = 'default.htm';
  4.     link.href = arr.join('/');
  5.     return true;
  6. }
Or second option is, you can add a function on the onload event of body.
Expand|Select|Wrap|Line Numbers
  1. function changeHrefsToDefaultHtm() {
  2.     var link = document.getElementsByTagName('a');
  3.     for (var i=0; i<link.length; i++)
  4.     //if (link[i].className=='searchLink')
  5.     {
  6.         arr = link[i].href.split('/');
  7.         arr[arr.length-1] = 'default.htm';
  8.         link[i].href = arr.join('/');
  9.     }
  10. }
But this will change all the links in your page, so its not recommended, unless you have something unique about the search result links.
Eg. If the class name is unique, remove forward slashes from line 4


Regards,
Harpreet
Apr 3 '08 #2
acoder
16,027 Expert Mod 8TB
The other option (if possible depending on how you have it set up) is to change each of those files to force them into the frame. Now if you're not using SSI (server side includes), this is not possible - well, it is, but it'd take forever to do.
Apr 4 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: phpkid | last post by:
Howdy I've been given conflicting answers about search engines picking up urls like: http://mysite.com/index.php?var1=1&var2=2&var3=3 Do search engines pick up these urls? I've been considering...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
2
by: jmensch | last post by:
Hello. I'm a reasonably new ASP.NET programmer with no prior ASP or web development experience, but a lot of general programming experience. I'm using Visual Web Developer Beta Express 2005. ...
10
by: tom | last post by:
hi group, i desperately need a function that will transform relative URLs to absolute URLs in the SRC part of <img> tags. ie: function makeAbsolute($html,$basehref) { //if regex match =...
10
by: jflash | last post by:
Hello all, I feel dumb having to ask this question in the first place, but I just can not figure it out. I am wanting to set my site up using dynamic urls (I'm assuming that's what they're...
0
by: replicant | last post by:
Hello. I am hoping someone here could point me in the right direction. I enjoy downloading and searching the web. It's a past time of mine. While I'm a relatively experienced computer user, I'm...
2
by: dbojan | last post by:
From this search engine: https://siteexplorer.search.yahoo.com/mysites when I make all subdomains search just by typing a domain url in a search box like blogspot.com -and after I verify my...
4
by: Guy Macon | last post by:
As a personal learning experience with limited practical use, I have been doing some experiments with using .htaccess to redirect mis-typed URLs to a preferred canonical form. I have set up a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.