473,322 Members | 1,504 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,322 software developers and data experts.

Re: Best way to break out of a frame

On Jul 27, 9:37*pm, Jonas Smith <jonas.sm...@yahoo.comwrote:
When I started my site a long time ago, I found out that some other site
was framing my site and serving ads around it, even though I had no ads.

At the time as a solution (and it worked) I added the following
Javascript statement to all my html files:

<body onload="if (window != window.top) {top.location.href =
location.href;}">

That surely breaks frames.

However, recently, few of my users have complained that the site keeps
reloading when accessed with a blackberry. All pages keep reloading
until stopped. I found the culprit to be the above JS statement.
Here somebody has regurgitated a lot of bad examples in a very bad
color scheme, but there are a couple of useful ideas to be found:

http://perishablepress.com/press/200...es-notes-plus/

Does the Blackberry even support frames? Perhaps it would be useful
to skip the test if window.frames is not a truthy object.

The other thing that escaped me before is window.self. Try comparing
that to window.top instead.
Jul 28 '08 #1
6 1867
On Aug 4, 12:30*pm, Jonas Smith <jonas.sm...@yahoo.comwrote:
On Mon, 28 Jul 2008 01:28:02 -0400, Jonas Smith wrote
(in article <488d58e2$0$614$9a6e1...@unlimited.newshosting.com >):
On Sun, 27 Jul 2008 22:48:14 -0400, David Mark wrote
(in article
<92f5db2e-d126-43c3-a770-39c580eb7...@z66g2000hsc.googlegroups.com>):
On Jul 27, 9:37*pm, Jonas Smith <jonas.sm...@yahoo.comwrote:
When I started my site a long time ago, I found out that some other site
was framing my site and serving ads around it, even though I had no ads.
>At the time as a solution (and it worked) I added the following
Javascript statement to all my html files:
><body onload="if (window != window.top) {top.location.href =
location.href;}">
>That surely breaks frames.
>However, recently, few of my users have complained that the site keeps
reloading when accessed with a blackberry. All pages keep reloading
until stopped. I found the culprit to be the above JS statement.
Here somebody has regurgitated a lot of bad examples in a very bad
color scheme, but there are a couple of useful ideas to be found:
>http://perishablepress.com/press/200...es-notes-plus/
Does the Blackberry even support frames? *Perhaps it would be useful
to skip the test if window.frames is not a truthy object.
The other thing that escaped me before is window.self. *Try comparing
that to window.top instead.
Thanks for the pointers, I made some changes and I am now waiting for my
volunteer tester to come back with results.

I'm now using:

<body onLoad="if (window.self!=window.top) {window.top.location =
window.self.location;}">
You are still breaking the back button! That is the single most
annoying blunder that a JS developer can make (see any of Google's
properties for lots of bad examples.) Use location.replace to avert
this problem.
Aug 4 '08 #2
On Aug 4, 6:30*pm, Jonas Smith <jonas.sm...@yahoo.comwrote:
On Mon, 28 Jul 2008 01:28:02 -0400, Jonas Smith wrote
(in article <488d58e2$0$614$9a6e1...@unlimited.newshosting.com >):


On Sun, 27 Jul 2008 22:48:14 -0400, David Mark wrote
(in article
<92f5db2e-d126-43c3-a770-39c580eb7...@z66g2000hsc.googlegroups.com>):
On Jul 27, 9:37*pm, Jonas Smith <jonas.sm...@yahoo.comwrote:
When I started my site a long time ago, I found out that some other site
was framing my site and serving ads around it, even though I had no ads.
>At the time as a solution (and it worked) I added the following
Javascript statement to all my html files:
><body onload="if (window != window.top) {top.location.href =
location.href;}">
>That surely breaks frames.
>However, recently, few of my users have complained that the site keeps
reloading when accessed with a blackberry. All pages keep reloading
until stopped. I found the culprit to be the above JS statement.
Here somebody has regurgitated a lot of bad examples in a very bad
color scheme, but there are a couple of useful ideas to be found:
>http://perishablepress.com/press/200...es-notes-plus/
Does the Blackberry even support frames? *Perhaps it would be useful
to skip the test if window.frames is not a truthy object.
The other thing that escaped me before is window.self. *Try comparing
that to window.top instead.
Thanks for the pointers, I made some changes and I am now waiting for my
volunteer tester to come back with results.

I'm now using:

<body onLoad="if (window.self!=window.top) {window.top.location =
window.self.location;}">

That seems to work with the blackberry browser without reloading.
But why window.self ?

window.self.location === window.window.location === window.location

Or not ?

--Jorge.
Aug 4 '08 #3
On Aug 4, 3:46*pm, Jorge <jo...@jorgechamorro.comwrote:
On Aug 4, 6:30*pm, Jonas Smith <jonas.sm...@yahoo.comwrote:
On Mon, 28 Jul 2008 01:28:02 -0400, Jonas Smith wrote
(in article <488d58e2$0$614$9a6e1...@unlimited.newshosting.com >):
On Sun, 27 Jul 2008 22:48:14 -0400, David Mark wrote
(in article
<92f5db2e-d126-43c3-a770-39c580eb7...@z66g2000hsc.googlegroups.com>):
>On Jul 27, 9:37*pm, Jonas Smith <jonas.sm...@yahoo.comwrote:
>>When I started my site a long time ago, I found out that some othersite
>>was framing my site and serving ads around it, even though I had noads.
>>At the time as a solution (and it worked) I added the following
>>Javascript statement to all my html files:
>><body onload="if (window != window.top) {top.location.href =
>>location.href;}">
>>That surely breaks frames.
>>However, recently, few of my users have complained that the site keeps
>>reloading when accessed with a blackberry. All pages keep reloading
>>until stopped. I found the culprit to be the above JS statement.
>Here somebody has regurgitated a lot of bad examples in a very bad
>color scheme, but there are a couple of useful ideas to be found:
>>http://perishablepress.com/press/200...es-notes-plus/
>Does the Blackberry even support frames? *Perhaps it would be useful
>to skip the test if window.frames is not a truthy object.
>The other thing that escaped me before is window.self. *Try comparing
>that to window.top instead.
Thanks for the pointers, I made some changes and I am now waiting formy
volunteer tester to come back with results.
I'm now using:
<body onLoad="if (window.self!=window.top) {window.top.location =
window.self.location;}">
That seems to work with the blackberry browser without reloading.

But why window.self ?
The OP seems to have settled on a pattern that works by coincidence.

This seems like a practical solution.

<body onload="if (window.self != window.top)
{ window.top.location.replace(window.location.href); }">

Of course, the location.replace method should be feature tested.

Also, there would seem no need to do this test at all if there is no
window.frames or window.frames.length is zero.




Aug 4 '08 #4
On Aug 4, 10:37*pm, David Mark <dmark.cins...@gmail.comwrote:
>
Also, there would seem no need to do this test at all if there is no
window.frames or window.frames.length is zero.
window.frames or window.top.frames ?

--Jorge.
Aug 4 '08 #5
On Aug 4, 5:05*pm, Jorge <jo...@jorgechamorro.comwrote:
On Aug 4, 10:37*pm, David Mark <dmark.cins...@gmail.comwrote:
Also, there would seem no need to do this test at all if there is no
window.frames or window.frames.length is zero.

window.frames or window.top.frames ?

--Jorge.
You could test if window.frames is a truthy object, and
window.frames.length is a number. A more direct test would also check
that window.top.frames.length is non-zero.
Aug 4 '08 #6
On Aug 11, 1:32*am, Jonas Smith <jonas.sm...@yahoo.comwrote:
[snip]
>
OK, by now my inexperience in this issue should be apparent.
Yes.
>
Can you explain what you what you mean?
I mean stop breaking the back button. If you click the back button
and your browser does a U-turn back to the page you were on, the
previous page broke the back button. It's a really stupid thing to do
and will annoy your users to no end.
>
First you complain about breaking the back button and then when I say
don't care about that part, you state that I should and somehow if I do
Of course you should. Why would you want to break your users' agents?
care about the back button and do it your way, my readers won't get back
to the offending site. How does that work exactly?
You have been told at least three times.
>
I don't break the button but the reader doesn't get back to the other
site by clicking the back button? To me that sounds a little
paradoxical.
It isn't. Try it and you'll see.
Aug 11 '08 #7

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

Similar topics

9
by: Michele Simionato | last post by:
Is there a way of "ending" a module? I would like something like this: # mod.py print 'something here' end() # some mysterious function print 'you should not get here' # main.py import mod...
4
by: Jubri Siji | last post by:
Please i am new to python , whats the best IDE to start with
1
by: Mikko Tussunen | last post by:
I wonder, what would be the best way to write content to another frame? Meaning that as many browsers as possible supports it. I have a frame that reloads with a 3 second interval, and depending...
3
by: Jianli Shen | last post by:
const DInst *stopAtDst = 0; while (dinst->hasPending()) { if (stopAtDst == dinst->getFirstPending()) break; ///////break? break? break? is this break outof the whole while loop and...
4
by: Will Hartung | last post by:
The designers have handed me a page that has 5 different blocks on it in the center column (in a typical 3 column layout with page spanning headers and footers). The blocks have elaborate...
3
by: Razvan | last post by:
Hello, Can somebody recommend me a Java Script scroller that can scroll an i-frame ? I tried the Tigra scroller (www.softcomplex.com/products/tigra_scroller/) but sometimes it does not...
9
by: Bill Borg | last post by:
Hello, I call a function recursively to find an item that exists *anywhere* down the chain. Let's say I find it five layers deep. Now I've got what I need and want to break out of that whole...
2
by: kwenterprise | last post by:
Hello All, I am normally great at figuring out ways around iframe issues that frustrate us all. I am using javasript to try and break an iframe that I have a banner rotator embedded in but it...
1
by: Muchach | last post by:
Hello, Ok so what I've got going on is a form that is populated by pulling info from database then using php do{} to create elements in form. I have a text box in each table row for the user to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.