Solved

Urgent! Linking banners!

Posted on 2000-03-21
6
171 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
  • 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now