• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

Correct Frames Page Meta Tags

How to I write a correct meta tag for the 'sub-pages' in a a Frames website?  For example, I have a domain name - www.mydomain.com which has three frames (navigation, Title, sub-pages).  I have META tags on all of my sub-pages so that they can be found by the search engines, but I DON'T what customers to go to those pages individually, i.e., www.mydomain.com/sub-form.htm -I wan't them to use the Frames page's navagation bar.

Is there a way to point the meta tags on the sub pages to my domain name's frames page, so that the search engines results display www.mydomain.com instead of www.mydomain.com/sub-form.htm -- regardless of which sub-page the search engine found?
0
d4jaj1
Asked:
d4jaj1
  • 6
  • 4
1 Solution
 
tecbuilderCommented:
Add this script into the header of each one of your framed pages.  This will check to see if you are in a framedpage and if not then it will load your page that contains the frameset info.

<SCRIPT LANGUAGE="JavaScript">
<!-- Hide script from older browsers
setTimeout ("changePage()", 3000);
function changePage() {
  if (self.parent.frames.length != 0) {
    if self.parent.location != 'http://www.mydomain.com'   // Check to see if the frames belong to you.
      self.parent.location=http://www.mydomain.com    // Go to page to create frames
  }
  else
   self.parent.location=http://www.mydomain.com     // No frames found so go to page to create frames
}
// end hiding contents -->
</SCRIPT>
0
 
d4jaj1Author Commented:
I get an error with this script.  The error is '(' expected.  Here's the HTML from my page.

<head>
<title>HomeBase Activity Manager Upgrades</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<script language="JavaScript">  
<!-- Hide script from older browsers  setTimeout ("changePage()", 3000);  
function changePage()
 {  if (self.parent.frames.length != 0)
   {  if self.parent.location != 'http://www.new-dimensions.net' // Check to see if the frames belong to you.  
    self.parent.location=http://www.new-dimensions.net // Go to page to create frames  }
  else  self.parent.location=http://www.new-dimensions.net // No frames found so go to page to create frames  }  
// end hiding contents -->  
</script>
</head>

By the way, do my META tags go above or below this script?
0
 
tecbuilderCommented:
Use this script instead.  It fixes a couple of typeos that I had.  I also changed it to use the history.replace("http://www.new-dimensions.net") function which will replace the current URL in the history list with the one specified.  I think this is better for what you are wanting.  I am not sure how NS handles the specfied URLs in the function so if you get an error try removing the http://s.

<SCRIPT LANGUAGE="JavaScript">
<!-- Hide script from older browsers

setTimeout ("changePage()", 3000);
function changePage() {
      if (self.parent.frames.length = 0)
            history.replace("http://www.new-dimensions.net") // No frames found so go to page to create frames
      else {
            if (self.parent.location != 'http://www.new-dimensions.net') // Check to see if the frames belong to you.
                  history.replace("http://www.new-dimensions.net") // Go to page to create frames
      }
}

// end hiding contents -->
</SCRIPT>

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
d4jaj1Author Commented:
Nope, that didn't work. I get an error - 'Function not support by this object.  Also, I don't see anu http://s in your code above.
0
 
tecbuilderCommented:
Use self.history.replace("http://www.new-dimensions.net)" or document.history.replace("http://www.new-dimensions.net)" in the function.
0
 
d4jaj1Author Commented:
This still does not work - using self or document.  Also, I moved the " inside of the bracket, as in you last comment I think you accidentlly put it outside of the bracket.  I get the same "Object doesn't support..." error.  Could you please test your answer before you post it to this question? Thanks.
0
 
tecbuilderCommented:
It did work on my computer, but I don't have immediate access to a server to load files to see what happens.

I did realize that I was making this much more difficult than it needed to be.  This should work for you.  Again, it does work on my machine.

<SCRIPT LANGUAGE="JavaScript">
<!-- Hide script from older browsers
setTimeout ("changePage()", 3000);

function changePage() {
if (self.parent.frames.length == 0)
  window.location="http://www.new-dimensions.net";
}

// end hiding contents -->
</SCRIPT>
0
 
tecbuilderCommented:
You also asked about where do META tags go.  They can be anywhere in the Heading.  I usually put them just after the <head> tag so they are easier to find.  There is no problem if you want META tags before or after JavaScript.
0
 
d4jaj1Author Commented:
Your last example seems to work and I will give you an A.  I do have two questions - just so I know what the code you gave me is actually doing.  The first part:

<!-- Hide script from older browsers
setTimeout ("changePage()", 3000);

What does this mean? Does it mean for browsers that don't support JAVA it won't change the page?  How would it know and would a run-time error dialog box appear?  What happens on browers that DO support JAVA, but simply have JAVA scripts turned off?

Secondly,

function changePage() {
if (self.parent.frames.length == 0)
window.location="http://www.new-dimensions.net";
}

The page acually loads - sits there for about 2 seconds, then redirects the user to the fames page.  Is ther a way not to load the page at all or make the redirect a little faster?  I tried to change the timeout - but that didn't work.

Those are my two qustions. I would like to make this alot better by redirecting the user to the frames page - without them seeing the sub-form and make the HTML page they initaillly visited teh active page in teh Frames form (as if ther had clickked the link with the frames form themselves).  I only want to implement this solution though if Netscape 3 & IE 3 and above can use it - so if these browsers don't support the answer you would give - I don't need it.  Finally - of course I would raise the points for the additional questions.
0
 
tecbuilderCommented:
I'm glad what I sent worked for you.  I don't know why I was making it out to be so difficult.  My apologies.  The answer's to your questions are:

1) <!-- Hide script from older browsers
setTimeout ("changePage()", 3000);

>>What does this mean?<<
'<!--' is used just after the <script> tag for those browsers that don't recognize scripts.  This in effect comments all of your code.  If you don't those browsers are going to display all of your scripts on their window.  Ugly.  Also, just before the </script> tag you need the '// -->' [note: don't use the single quotes].  This ends the comment.

The setTimeout function says to wait 3000 milliseconds and then execute the function changePage.

>>Does it mean for browsers that don't support JAVA it won't change the page?  How would it know and would a run-time error dialog box appear?<<
No.  It has nothing to do with Java.  Browser either can or cannot run Java.  Those that can't, whether they unselected the option or they have an old or a text browser won't do anything.  No run-time error box will appear.
 
>>What happens on browers that DO support JAVA, but simply have JAVA scripts turned off?<<
The code won't work.  If you want a work always solution then you will need to do it at the server via CGI, Perl, or server-side JavaScript (aka LiveWire).  This answer was for the client-side JavaScript.  There is no way of getting around this at the client-side.

2) function changePage() {
     if (self.parent.frames.length == 0)
     window.location="http://www.new-dimensions.net";
   }

>>The page acually loads - sits there for about 2 seconds, then redirects the user to the fames page. Is ther a way not to load the page at all or make the redirect a little faster?<<
To speed this up decrease the number of milliseconds in the setTimeOut function.  For your situation, you may be able to make this a pretty small number say 500 or so.  How much of a pause you need will have to come via trial-and-error.  I would start out with 500 and see how everything works.  Keep decreasing the number until it doesn't.  Try to use a couple of different sped computers during testing.

>>I tried to change the timeout - but that didn't work.<<
This should have worked.  You may need to reload the page while it's waiting since the old page was in the cache and most likely being used.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now