473,748 Members | 4,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

frames revisted - friendly rediect

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

Some friendlier ones do this:
if(top==self) document.write( '<a href=frameset>T his 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.locatio n; } 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.s earch 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 1517
Ivo wrote:
Dear Newsgroup,
many framed sites have an ancient script in all their pages:
if(top==self) top.location=th eframeset
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>T his 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.locatio n; } 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="myFramese t.html?somethin g">

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.s earch 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.javas cript 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=th eframeset


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.locatio n; } 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="myFramese t.html?somethin g">

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


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

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

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

So how would I read top.location.se arch 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="myFramese t.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.javas cript FAQ - http://jibbering.com/faq/
Jul 23 '05 #4
Ivo
"Randy Webb" wrote
Ivo wrote:
"Randy Webb" wrote
Ivo wrote:
<--snip-->
<a href="myFramese t.html?somethin g">

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

So how would I read top.location.se arch 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.javas cript FAQ - http://jibbering.com/faq/

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

Ivo wrote:


<--snip-->
<a href="myFramese t.html?somethin g">

And then search for that something, if its there, then dont display the
link, otherwise do.
So how would I read top.location.se arch 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.referr er. 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.referr er 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.referr er 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.javas cript 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
2968
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 address bar instead of every single variable and value being passed ;) a cleaner look imo. anyways, my index.htm looks like this: <html> <head> <title>mydomain.com</title>
95
5767
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? For most markup I know when it's useful and when it's not, but regarding table markup I sure know when it isn't good, but can't really come up with a way it would be good. As you all are among the sharpest pencils in the bag, let me ask: Do you...
2
3817
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. I want to do a site similar to frames. I've read over and over "ditch the frames" I'd like to have a header, body left with two columns of thumbnails and body right where one can click on a thumbnail and a larger image will come up. This is...
21
2951
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 frame contains a menu. The reason I need two levels is because each menu item needs different UPPER_RIGHT and LOWER_RIGHT frames. I just found that I could not nest frames. Can someone please tell how to write such a web page? thank you
2
3993
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
3032
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 news group posts). Despite the trouble they cause, it is still tempting to use frames, occasionally, for instance for machine-generated pages that might have a large number of left-side navigation links. If you do use frames in that...
11
2216
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 HTML file. It never needs to be reloaded and JS variables can be updated there as the visible screens progress. But...if I want to be a good internet samaritan and not use frames, what's the best way to replace that function?
2
1745
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 SEO. Is it possible to achieve it via cookies/sessions?
14
7063
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. I'll appreciate any help/example you can provide. I am using visual studio 2005. Thanks, Mark
0
8987
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9534
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2211
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.