473,385 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

frames revisted - friendly rediect

Ivo
Dear Newsgroup,
many framed sites have an ancient script in all their pages:
if(top==self) top.location=theframeset

Some friendlier ones do this:
if(top==self) document.write( '<a href=frameset>This page is '
+ 'supposed to be frames</a>.' )

These scripts fail when the page is loaded within somebody's else's
frameset.
Then top is not self but not a very cooperative top either. And with ever
growing security issues browsers have become quite paranoid. Even testing
for top's origin results in an error:

alert(top)
// gives me [object]
var s=''; for (var i in top) s+=i+'\t'+top[i]+'\n'; alert(s);
var obj; try{ obj=top.location; } catch(e) { obj=''; }
// give me [access denied] (of course)

I 'd rather drop the frames altogether, but the site has been like this for
years and the client insists. There are frames. So how would I detect when
it is appropriate to write:
<a href=>View this page in its <b>own</b> frames.</a> ?

Question b:
in the frameset, a little script looks into self.location.search for an url
with which to fill the main frame. Is there a way to avoid document.write
and onload?

Thanks,
Ivo
Jul 23 '05 #1
5 1503
Ivo wrote:
Dear Newsgroup,
many framed sites have an ancient script in all their pages:
if(top==self) top.location=theframeset
Usually it is the other way around, where most pages check to see if its
being framed and breaking out. But those do exist as well where it wants
it pages back in frames. The MSDN site is the first one that comes to
mind that will put a page back in its frameset.
Some friendlier ones do this:
if(top==self) document.write( '<a href=frameset>This page is '
+ 'supposed to be frames</a>.' )

These scripts fail when the page is loaded within somebody's else's
frameset.
Then top is not self but not a very cooperative top either. And with ever
growing security issues browsers have become quite paranoid. Even testing
for top's origin results in an error:

alert(top)
// gives me [object]
var s=''; for (var i in top) s+=i+'\t'+top[i]+'\n'; alert(s);
var obj; try{ obj=top.location; } catch(e) { obj=''; }
// give me [access denied] (of course)

I 'd rather drop the frames altogether, but the site has been like this for
years and the client insists. There are frames. So how would I detect when
it is appropriate to write:
<a href=>View this page in its <b>own</b> frames.</a> ?
<a href="myFrameset.html?something">

And then search for that something, if its there, then dont display the
link, otherwise do.
Question b:
in the frameset, a little script looks into self.location.search for an url
with which to fill the main frame. Is there a way to avoid document.write
and onload?


That was a technique I had employed for a while (before I abandoned
frames), was using a search string for two purposes. First was to find
out if it was actually in my frameset or not. The search string was
added dynamically by my scripts, so that it wasn't that easy to put my
sub-frame pages in someone elses frameset. The second purpose was so
that my frameset page could know which pages to display, based on the
search string.

Without doing it on the server, you are pretty much limited to the
search string and document.write'ing the frame tags.....

Hope this helps.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #2
Ivo
"Randy Webb" wrote
Ivo wrote:
Dear Newsgroup,
many framed sites have an ancient script in all their pages:
if(top==self) top.location=theframeset


Usually it is the other way around, where most pages check to see if its
being framed and breaking out. But those do exist as well where it wants
it pages back in frames. The MSDN site is the first one that comes to
mind that will put a page back in its frameset.


Since the only test on the MSDN pages I looked at, is (top==self), I can
easily put their pages in my own frameset... I don't even mind being framed
by another site (as long as they 're Google) but just want to detect when
this is happening..

<snip>
alert(top)
// gives me [object]
var s=''; for (var i in top) s+=i+'\t'+top[i]+'\n'; alert(s);
var obj; try{ obj=top.location; } catch(e) { obj=''; }
// give me [access denied] (of course)

I 'd rather drop the frames altogether, but the site has been like this for years and the client insists. There are frames. So how would I detect when it is appropriate to write:
<a href=>View this page in its <b>own</b> frames.</a> ?


<a href="myFrameset.html?something">

And then search for that something, if its there, then dont display the
link, otherwise do.


So how would I read top.location.search when access to top.location is
already denied?

Thanks,
Ivo
Jul 23 '05 #3
Ivo wrote:
"Randy Webb" wrote
Ivo wrote:
<--snip-->
<a href="myFrameset.html?something">

And then search for that something, if its there, then dont display the
link, otherwise do.

So how would I read top.location.search when access to top.location is
already denied?


Simple scenario:

----------------------------
| | |
| | |
| | |
| nav | main |
| | |
| | |
-----------------------------

All the links in the nav frame would have a search string appended. When
the links are clicked, to load them into main, when the page is loaded
you check location.search for that search string. If it exists, then you
don't display the link back to the frameset. If it doesn't exist, then
you display it.

<a href="myFrameset.html?thisPage.html">Frame this page</a>

When the frameset is loaded, it checks its own search string. If it
finds it, then it knows what page to display in the frameset.

You would also have to check top==self. If someone right clicks and Adds
to Favorites, then it would have the search string appended. When I was
doing it, I was using the current time as the search string, if the
search string was more than 60 minutes old, it kicked it out to the
frameset. I don't have those pages anymore though so I can't dig it out,
I am going on memory.

If I am still not making sense, I could try to throw together a sample
set later tonight.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #4
Ivo
"Randy Webb" wrote
Ivo wrote:
"Randy Webb" wrote
Ivo wrote:
<--snip-->
<a href="myFrameset.html?something">

And then search for that something, if its there, then dont display the
link, otherwise do.

So how would I read top.location.search when access to top.location is
already denied?


Simple scenario:


<snip scenario>

You have a great solution but not for the issue I tried to describe. Unless
the answer is I need to append search strings to all my internal links in
order to catch the rare occasion somebody is framing my page. But that 'd be
a dubious solution imho. If my page shows up in Google Images, my page is
framed by Google and will probably have that search string attached
automatically; if a human goes through the trouble of linking to my site, he
will also be(come) aware of my script. Again, I don't mind being framed, I
just want to know when to document.write

<a href=>View this page in its <em>own</em> frames.</a>
If I am still not making sense, I could try to throw together a sample
set later tonight.
That 'd be interesting anyway.
Thanks,
Ivo
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 23 '05 #5
Ivo wrote:
"Randy Webb" wrote
Ivo wrote:
"Randy Webb" wrote

Ivo wrote:


<--snip-->
<a href="myFrameset.html?something">

And then search for that something, if its there, then dont display the
link, otherwise do.
So how would I read top.location.search when access to top.location is
already denied?


Simple scenario:

<snip scenario>

You have a great solution but not for the issue I tried to describe. Unless
the answer is I need to append search strings to all my internal links in
order to catch the rare occasion somebody is framing my page. But that 'd be
a dubious solution imho. If my page shows up in Google Images, my page is
framed by Google and will probably have that search string attached
automatically; if a human goes through the trouble of linking to my site, he
will also be(come) aware of my script. Again, I don't mind being framed, I
just want to know when to document.write

<a href=>View this page in its <em>own</em> frames.</a>


I thought about it more last night, and realized what you were trying to
do. I mis-read it. if (top != self) seems to be the only way to know,
without errors, whether its in a frame or not. You have no way of
knowing whether its your frames or not, because of the cross-domain
security issues you mentioned with the top and self approach.

It seems that your best approach would be document.referrer. If its not
your frameset (full URL), then its either not in frames, or its in
someone elses frameset. And then produce the link. When testing, just
know that IE will give an empty string for document.referrer when
offline (I have never understood why it does that though)

This page: http://www.hikksworld.com/frames/frameset1.html

Is one that I made for another post I answered today, but the right hand
frame alerts its document.referrer as
http://www.hikksworld.com/frames/frameset1.html

If it is not in the frameset, or its in someone else's frameset, then it
will alert differently. So, checking it can tell you whether to write
the link or not.

Hope this helps.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: fartsniff | last post by:
hello all, i am using FRAMES on my PHP site, basically i am using just on frame with the entire site inside. this is mainly for cosmetics so that http://www.mydomain.com always is displayed in the...
95
by: Neal | last post by:
Of course, every frame site I've ever seen has reduced usability and all. We've been through this before. But as frameset is still a part of HTML, there must be some legitimate use for it, hmm?...
2
by: eloise | last post by:
Hi All I am a total newbee. I've done a site in Dreamweaver. I call it my learning site. I learned that I needed to learn some html and css. And then I learned I need to know more html and css....
21
by: bird | last post by:
I want to write a multi-frame web page. At level one, it has two frames, saying LEFT and RIGHT. At level two, I split the RIGHT frame into two again, saying UPPER_RIGHT and LOWER_RIGHT. The LEFT...
2
by: User10 | last post by:
Can some one provide an algorithm for motion detection between two jpeg frames? Or can you provide a more appropriate group to post this on? Thanks!
4
by: Sandy.Pittendrigh | last post by:
I don't want to get into a frames discussion here. We all know they have numerous drawbacks, especially with search engine visibility. (Google, ironically, uses framesets for displaying individual...
11
by: Kent Feiler | last post by:
One thing I like about frames is that they're a good place to stow Javascript. Javascript that I'd like to be around while the visible content of the screen changes goes in the frame declaration...
2
by: Suresh P | last post by:
Hi All, Is there any way other than frames to play music in the background of the website without restart while navigating to different pages of the website. Because, frames will affect the...
14
by: Mark | last post by:
Hi Guys, I am very new to ASP.NET world. I need to create three frames. One at the top, one on the left and another on the right side. I don't know how to do it. So please help me with it. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...

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.