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

Detect which IFrame is trying to change the top level document href/URL?

I have a comparison web page that has several iframes that contain documents
from external domain web sites. Some of the web sites are "trusted". If
they want to change the top level document location (document.location.href)
via Javascript or using "_TOP" as the target for a SUBMIT operation, etc.,
then I want to allow it. The other web sites I want to block if they try to
do that. I would do the blocking in the top level document onunload() event
handler.

Is there a way to know _which_ IFrame is trying to change the top level
document URL. I know I can't do anything to examine the contents of an
external domain sourced IFrame, due to browser security issues, but I was
hoping there might be something from an event handler standpointthat would
allow me tp grab the ID or NAME attribute of an IFrame, that triggers a top
level document location change. Note: I mean the ID or NAME attribute that
I assigned to the IFrame Node element that resides in _my_ document's, the
top level document, domain space.

Any ideas?

thx

--

Robert Oschler
"Let the web hear you, add your voice to your web site in minutes!"
-- http://audiodirect.spiderchase.com/
(For a limited time, free voiceover with every sign-up, use this link
instead)
-- http://audio.spiderchase.com/
(A song - are you blue?)
-- http://bluedreams.spiderchase.com/
Jul 20 '05 #1
4 8527
I'm sorry that I can't be more helpful, but all I can be pretty certain
of is that you can't prevent the unloading of a page. Imagine the hassle
that annoying ad-pages could cause if they could prevent the unload of
the page whenever they wanted ... unfortunately you may need another
solution?

Fred Basset
fr*********@whosyourdaddy.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #2
"Fred Basset" <fr*********@whosyourdaddy.com> wrote in message
news:3f***********************@news.frii.net...
I'm sorry that I can't be more helpful, but all I can be pretty certain
of is that you can't prevent the unloading of a page. Imagine the hassle
that annoying ad-pages could cause if they could prevent the unload of
the page whenever they wanted ... unfortunately you may need another
solution?

Fred Basset
fr*********@whosyourdaddy.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Fred,

Perhaps I misunderstand you but I've been very successful preventing the
unload of a page with:

// Between head tags.
<SCRIPT>
var gCurrentURL = document.location.href;
</SCRIPT>

// Function called by BODY onunload() event.
function onBodyUnload()
{
// This prevents the URL change by resetting the document
// document.location.href property to the current URL.
// This is where I would put the logic, if I knew how, to prevent the
URL
// change if an "untrusted" IFrame tried to change the top level URL.
document.location.href = gCurrentURL;
}

thx
--

Robert Oschler
"Let the web hear you, add your voice to your web site in minutes!"
-- http://audiodirect.spiderchase.com/
(For a limited time, free voiceover with every sign-up, use this link
instead)
-- http://audio.spiderchase.com/
(A song - are you blue?)
-- http://bluedreams.spiderchase.com/
Jul 20 '05 #3
My apologies!! I'm not having a good morning today obviously.

Just tried your code, and it works exactly as you say. I could've sworn
I've tried to do exactly that same thing previously and not been able to
... I'll just go tuck into my humble pie :)

Fred Basset
fr*********@whosyourdaddy.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4
Some thoughts (none tested):

In your code below, doesn't it do a refresh the way
that you have it? If so, couldn't you rather cancel the
event to avoid the refresh?

Also, since you are setting document.location.href to
something, my thought is what is that value that is
then in there? Is it already the hopeful new document's
href? If so, and if the number of trusted sites is
"reasonably finite" (after all, to trust a site you should
know it, right?) then you could cancel the event or
use your technique if the purported destination is
one of the trusted domains

Lotta ifs...

Good luck,
Csaba Gabor

"Robert Oschler" <no_replies@fake_email_address.invalid> wrote in message
news:lt*********************@news2.news.adelphia.n et...
"Fred Basset" <fr*********@whosyourdaddy.com> wrote in message
news:3f***********************@news.frii.net...
I'm sorry that I can't be more helpful, but all I can be pretty certain
of is that you can't prevent the unloading of a page. Imagine the hassle
that annoying ad-pages could cause if they could prevent the unload of
the page whenever they wanted ... unfortunately you may need another
solution?

Fred Basset
fr*********@whosyourdaddy.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Fred,

Perhaps I misunderstand you but I've been very successful preventing the
unload of a page with:

// Between head tags.
<SCRIPT>
var gCurrentURL = document.location.href;
</SCRIPT>

// Function called by BODY onunload() event.
function onBodyUnload()
{
// This prevents the URL change by resetting the document
// document.location.href property to the current URL.
// This is where I would put the logic, if I knew how, to prevent the
URL
// change if an "untrusted" IFrame tried to change the top level URL.
document.location.href = gCurrentURL;
}

thx
--

Robert Oschler
"Let the web hear you, add your voice to your web site in minutes!"
-- http://audiodirect.spiderchase.com/
(For a limited time, free voiceover with every sign-up, use this link
instead)
-- http://audio.spiderchase.com/
(A song - are you blue?)
-- http://bluedreams.spiderchase.com/

Jul 20 '05 #5

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

Similar topics

7
by: Vincent van Beveren | last post by:
Hi everyone I have a JavaScript app that creates an IFRAME through DOM (createElement('IFRAME')) However, that IFRAME does not have any content yet. ...
5
by: Jim Marquardson | last post by:
Hi, I've struggled with this for a while now, so I'm asking for help. I am trying to click on a link in one page, have that link open up in a new window, and set that newly opened window's...
5
by: Mel | last post by:
i need to have 2 side by side iframes, a link on top of the one will show/hide the other can someone help me pleeeeezzzzz ?
3
by: coolsti | last post by:
I need some help here. I am making an application which allows a user to look at a series of picture files one at a time, and enter the outcome of various visual tests to a database. The...
3
by: Asterbing | last post by:
Since the "on fly addition..." thread has taken another direction, I'm opening a new one to be more explicit and recenter the subject. Well, the subject is to detect when a document is well...
1
by: Anil | last post by:
Hello, In line 8 below, I am trying to set the content of the iframe, but receive an error. Movie 2 plays normally. Movie 1 fails. This example is from the QuickTime docs. (example...
2
riptide2049
by: riptide2049 | last post by:
I really have a problem here. I have a code that is suppost to take the href of a link from the right class;value of a link maked toreturn false. the value is a Media file the file is sent to...
0
by: tequilamala | last post by:
I have an Iframe in one of the pages i am developing... the iframe is suppose to scroll up and down and the links target the iframe. the problem is that the iframe scrolls side to side on internet...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.