473,789 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change URLs in search results

1 New Member
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.ht m" if it finds one of the htm pages in the URL.

The htm files to change are as follows:

doc_index.htm
document_histor y.htm
frame_menu.htm
project_history .htm
status.htm
status_history. htm
summary.htm
task_history.ht m
task_list.htm
terms.htm
terms_history.h tm

Is there a quick and easy way to do this?

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

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 Recognized Expert Moderator MVP
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
3426
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 converting a site of mine to PHP-Nuke, but if the individual modules aren't picked up in search engines I'm not going to do it. Thanks phpKid
4
2635
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 QA tested for a new year release. I don't think that going to prove practical, but there is no harm in trying :) and some serious family commitments. But it has to be done soon so this is stage one. Mike Winter provided an extensive list of...
2
2138
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. I'm trying to find a way to store data in the URL of my pages. I know that SessionState does this if you go cookieless, and that's useful but it's not what I want because the real data is stored on the server, and only an ID code is
10
3162
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 = relative URL ==> return img tag with absolute URL
10
4939
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 called, an example of what I have in mind is index.php?page=). However, I can not figure out how to do this. I will eventually want to use SEF urls, but for now I'll be content just to have the dynamic urls. If anyone can tell me how to do this, I'd...
0
1128
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 only a button pusher who doesn't understand code so needs a GUI with the program. Here's my problem. My desktop search engine will only export search results in XML format. My web page download software will only import IE favorites. How can I turn...
2
1705
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 yahoo email password I get 28 millions webpages listed on thousands of search result pages.I want to save the all urls and again only the one that have flv files in a text file so some flash downloader preferably freeware could preview or download...
4
4871
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 test page at http://www.guymacon.org/test.html ] to show the results of my testing. Most of the URLs redirect as I want them to do, but the three URLS (with "//" instead of "/") in bold do not redirect. I have searched the web and have not...
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10412
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3703
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.