473,387 Members | 1,497 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.

iFrame, getSelection(), and unauthorized access

I'm trying to figure out a way to have JavaScript use getSelection()
with text located in an iFrame. I've been able to make it work, but only
when the iFrame displays a page located on the parent page's domain.
When the iFrame displays pages on other domains, I get an error --
something about unauthorized access. I'm guessing the error stems from
concerns about scripting attacks.

Is there any workaround? I was thinking about copying the selection to
the clipboard, and then pasting it into the desired location, but that
seems a bit clunky, and I don't know if it'll work in any case.

Thanks for any help.

--Brent
Apr 21 '07 #1
5 3130
Hi Brent,

On Apr 21, 10:39 am, Brent <""b b i g l e r \"@ y a h o o . c o m">
wrote:
I'm trying to figure out a way to have JavaScript use getSelection()
with text located in an iFrame. I've been able to make it work, but only
when the iFrame displays a page located on the parent page's domain.
When the iFrame displays pages on other domains, I get an error --
something about unauthorized access. I'm guessing the error stems from
concerns about scripting attacks.
Yes it is a security restriction.
Is there any workaround?
I don't think so.
I was thinking about copying the selection to
the clipboard, and then pasting it into the desired location, but that
seems a bit clunky, and I don't know if it'll work in any case.
Copying to the clipboard works in IE through JavaScript or with a
browser running Flash (which can be controlled by JavaScript.)

Peter

Apr 21 '07 #2
Peter Michaux said the following on 4/21/2007 1:58 PM:
Hi Brent,

On Apr 21, 10:39 am, Brent <""b b i g l e r \"@ y a h o o . c o m">
wrote:
>I'm trying to figure out a way to have JavaScript use getSelection()
with text located in an iFrame. I've been able to make it work, but only
when the iFrame displays a page located on the parent page's domain.
When the iFrame displays pages on other domains, I get an error --
something about unauthorized access. I'm guessing the error stems from
concerns about scripting attacks.

Yes it is a security restriction.
With a very simple example to show the flaw :-) Suppose I put your bank
page in a 100% IFrame. Would you want my page to be able to read the
information from your Bank site? :-)
>Is there any workaround?

I don't think so.
There isn't.
>I was thinking about copying the selection to
the clipboard, and then pasting it into the desired location, but that
seems a bit clunky, and I don't know if it'll work in any case.

Copying to the clipboard works in IE through JavaScript or with a
browser running Flash (which can be controlled by JavaScript.)
That won't work either for the same reason. You can't read it from the
parent and you can't paste to the child from the parent. Same Security
issue.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 21 '07 #3
"Randy Webb" <Hi************@aol.comwrote in message
news:sa********************@giganews.com...
Peter Michaux said the following on 4/21/2007 1:58 PM:
>Hi Brent,

On Apr 21, 10:39 am, Brent <""b b i g l e r \"@ y a h o o . c o m">
wrote:
>>I'm trying to figure out a way to have JavaScript use getSelection()
with text located in an iFrame. I've been able to make it work, but only
when the iFrame displays a page located on the parent page's domain.
When the iFrame displays pages on other domains, I get an error --
something about unauthorized access. I'm guessing the error stems from
concerns about scripting attacks.

Yes it is a security restriction.

With a very simple example to show the flaw :-) Suppose I put your bank page in a 100%
IFrame. Would you want my page to be able to read the information from your Bank site?
:-)
>>Is there any workaround?

I don't think so.

There isn't.
>>I was thinking about copying the selection to
the clipboard, and then pasting it into the desired location, but that
seems a bit clunky, and I don't know if it'll work in any case.

Copying to the clipboard works in IE through JavaScript or with a
browser running Flash (which can be controlled by JavaScript.)

That won't work either for the same reason. You can't read it from the parent and you
can't paste to the child from the parent. Same Security issue.
I cannot help but think that "dynodes" could assist in this matter. Or modified to
assist.

No... yes... ?

-Lost
Apr 22 '07 #4
On Apr 21, 10:34 pm, "-Lost" <maventheextrawo...@techie.comwrote:
"Randy Webb" <HikksNotAtH...@aol.comwrote in message
Copying to the clipboard works in IE through JavaScript or with a
browser running Flash (which can be controlled by JavaScript.)
That won't work either for the same reason. You can't read it from the parent and you
can't paste to the child from the parent. Same Security issue.
I didn't make it clear that I was just talking about copying to the
clipboard in general.

I cannot help but think that "dynodes" could assist in this matter. Or modified to
assist.

No... yes... ?
I doubt it but what are "dynodes"?

Peter

Apr 22 '07 #5
Peter Michaux said the following on 4/22/2007 1:49 AM:
On Apr 21, 10:34 pm, "-Lost" <maventheextrawo...@techie.comwrote:
<snip>
>I cannot help but think that "dynodes" could assist in this matter. Or modified to
assist.

No... yes... ?

I doubt it but what are "dynodes"?
It is a crazy stupid name someone dreamed up to describe dynamic script
insertion. And no, it won't work for this situation.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 22 '07 #6

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

Similar topics

1
by: Martin | last post by:
There seems to be some strange behaviour when trying to get the scrollHeight and scrollTop of an iframe in IE6. I have tried several ways of getting these values when the iframe is written into...
9
by: Ragnorack67 | last post by:
.... <div id=work>hello</div> .... <IFRAME id="thisframe" src="./something.htm"></IFRAME> <script>
1
by: chaitatp | last post by:
Hi friends, I've got a problem about inserting Flash in iframe in Firefox. The codes are: ---- test.html ---- <html> <head> <script type="text/javascript"> function doBodyOnLoad()
14
by: Aaron Gray | last post by:
Hi, I want to access the properties of an IFrame but seem unable to get access to the IFrames document body. <html> <body> <iframe src="test.html" id="IFrame"></iframe> </body>
6
by: PD | last post by:
I have a parent .Net page (http://mywebsite/project.aspx) that has an iframe (http://iframe/iframe.aspx) which are on seperate domains. I need to adjust the scrolling on the parent window due the...
0
by: Bank of America | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
5
by: brad | last post by:
I'll post my code below. My goal is to grab the selected text in an iFrame from javascript (really any way possible). When I highlight text in the iFrame and click the link outside of the iFrame, I...
1
by: fniles | last post by:
In my ASPX page I included the following iframe: <iframe align="right" marginWidth="0" marginHeight="0" src="http://ipaddress/mywebsite/mypage.aspx" frameborder="0" scrolling="no" width="218"...
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: 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:
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
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
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,...
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.