Solved

Urgent! Linking banners!

Posted on 2000-03-21
6
182 Views
Last Modified: 2010-04-09
Hello all,
   I have a page called index.htm which consists of toc.htm as the left frame and main.htm as the right frame.

toc.htm has links like Hiring, Downloads etc. These links open in my main.htm when they are clicked.
Now I have an external link from some other page to just hiring.htm

But it only opens that page not in my frame. What is the way to link to any of my pages and at the same time keep toc.htm as the frame?

Thanks,
-Hocam
0
Comment
Question by:Hocam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:jbirk
ID: 2643147
With a little javascript, you can detect when a person enters you site without the frames, and then send them to the framed version.  The using the search string in the url have the frameset change the href of a frame based on that value.

code to follow...


-Josh
0
 
LVL 8

Accepted Solution

by:
jbirk earned 50 total points
ID: 2643186
OK, here's the frameset code:
<SCRIPT language="JavaScript">
<!--
function load_frame()
{

var search = location.search;
if (search.length > 0)
 {
  search = search.substr(1); //gets rid of '?'
  var strArr= search.split('=');
  if (strArr[0] == "left")
   top.left.location=strArr[1];
  else if (strArr[0] == "right")
   top.right.location=strArr[1];
 }

}
// -->
</SCRIPT>
<!-- frames -->
<frameset  cols="50%,*" onload="load_frame();">
<frame name="left" src="left.html">
<frame name="right" src="right.html">
</frameset>


Then on the left frame pages, this code goes at the beginning of the document:
<SCRIPT language="JavaScript">
<!--
if (top.location==location)
 location='index.html?left='+location;
// -->
</SCRIPT>

and the right frame pages:

<SCRIPT language="JavaScript">
<!--
if (top.location==location)
 location='index.html?right='+location;
// -->
</SCRIPT>


Hopefully you get the idea.  Just change the names of the frames accordingly.  If there's something you don't understand, feel free to ask.

-Josh
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 2643190
Syntax may be wrong, but you can place code in hiring.htm that checks to see if it is in a frameset, if not redirect to a frameset with toc and hiring in it.

<script languange="JavaScript">
<!--
   if(parent.frames.length=0)      window.top.location.replace="framesetHiring.htm";
//-->
</script>

where framesetHiring.htm is a second frameset to your site that will open with toc and hiring already open.

davlun
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:davlun20080
ID: 2643199
Josh, you beat me again.  This time by two minutes.  One of these days I'll get in on time....

As a side note, I don't understand how your script will work.  If you are following a link like www.smith.com/hiring.htm that would open the file hiring.htm on it's own, how does your script move it to the frameset.  It looks like the link he would be giving out would be to a frameset then?

davlun
0
 
LVL 8

Expert Comment

by:jbirk
ID: 2643209
If the link is to a single html page with no frameset, it loads up the frameset and tells the frameset which page to load in which frame.  This way the person also can't view the frames individually apart from the frameset.

The
location='index.html?right='+location;
command loads the frameset (named index.html here) and tells it to load the current location into the right frame, since it's supposed to be in the frame of this frameset.  This way the default right page can be overriden by the page that's wanted (perhaps even a couple levels deep into site?)

-Josh
0
 
LVL 1

Author Comment

by:Hocam
ID: 2645328
Perfect answer...!!!
I have added increased the points to 60 for you!

Thank you!
-Hocam
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question