Avatar of mpalmati
mpalmati
 asked on

find parent frameset AND preserve page

I've looked all over for something that works, here is my challenge:

If clients search for employee webpages in our site, they can link directly to those pages.  I've put in some javascript to redirect them back to the frameset page:

if (window == top) top.location.href = "../../index.htm";

but I can't find a way to preserve the page they came from.  I've tried using URL strings (e.g., page.htm?id=thispage.htm,

but I'm not allowed to use server-side scripts to process redirects at the other end...meaning I need javascript that preserves the location of the page the clients were trying to access to begin with, or, some reliable way to read a URL string in javascript (I've found some that are either unreliable or too complicated for me)

Matt
Web Languages and StandardsJavaScript

Avatar of undefined
Last Comment
ADT

8/22/2022 - Mon
ADT

Perhaps you can set a cookie to record the location and retrieve it later.

ADT
mpalmati

ASKER
forgot to mention I stink at javascript...
any ideas how???
mpalmati

ASKER
one other thing, how could I take (what method)

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

and opent the name cookie in the right frame???
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
ADT

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ADT

better end with:

MyPage=getCookie(nameOfCookie);
if(MyPage!=null){
  document.write("<frame name='TheName' src='" + MyPage + "' frameborder='no'>");
}else{
  document.write("<frame name='TheName' src='TheNormalPage' etc..>;
}

ADT
mpalmati

ASKER
Thanks for the help ADT, but I found a workaround without using cookies:
I used the writeline method to create the frameset
with a substring condition

     linkURL = "content.htm"
     if (parent.document.URL) {
          callingURL = parent.document.URL
          if (callingURL.indexOf('?') != -1) {
               linkURL = callingURL.substring(callingURL.indexOf('?')+1,callingURL.length)
          }
     }

     document.writeln('<frameset rows="70,395" cols="166,637" frameborder="NO" border="0" framespacing="0"> ')
     document.writeln('<frame src="title.htm" name="title" frameborder="NO" scrolling="NO" bordercolor="#000033">')
     document.writeln('<frame src="header1.html" name="title2" scrolling="NO" frameborder="NO">')
     document.writeln('<frame src="flashdetect.htm" name="nav" scrolling="NO">')
     document.writeln('<FRAME SRC="' + linkURL + '" NAME="content">')
     document.writeln('</frameset>')


Then pasted the relocation with a string parameter in each individual page:

if (top.location == self.location) {
               self.location.replace("../../index.htm?dept/faculty/albert_einstien.shtml")
          }

So simple...too bad I don't bill by the hour...too bad my employer loves frames.

once I figured out the writeln method, I could add whatever script i wanted to the frame source...can't take any credit though:
http://www.chalcedony.com/javascript/scripts/
ADT

congrats, you found a better solution and a good address too!

regards
ADT
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.