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

cross frame scripting

<html>
<head>
<title>Cross Frame Reference</title>
<script language="javascript">
function showThisTitle() {
alert(document.title);
}
function showAnotherTitle() {
try {
alert(anotherWorld.document.title);
}
catch (e) {
alert(e);
}
}
</script>
</head>
<body>
<iframe width="100%" height="50%" name="anotherWorld"
src="http://www.google.co.kr/"></iframe><br><br>
<div align="center">
<input type="button" value="Show this title"
onClick="showThisTitle();">
<input type="button" value="Show iframe's title"
onClick="showAnotherTitle();">
</div>
</body>
</html>

in the code above, i cannot get the document title of iframe.
i have understood it was because of security problem.

how can i get the title, (location.)href or (domain.)url of iframe
beyond security problem?

Dec 26 '05 #1
3 10179
You can't :), mozilla points out to using a signed script, meaning, a
script with some certificate to disable the security, coming from the
domain loaded in the frame, but all that's on the server, not client.

Danny
Dec 26 '05 #2
On 2005-12-26, Vongza <pa****@gmail.com> wrote:

in the code above, i cannot get the document title of iframe.
i have understood it was because of security problem.

how can i get the title, (location.)href or (domain.)url of iframe
beyond security problem?


serve its content from the same server as the main document.

--

Bye.
Jasen
Dec 26 '05 #3


Vongza wrote:

<iframe width="100%" height="50%" name="anotherWorld"
src="http://www.google.co.kr/"></iframe> how can i get the title, (location.)href or (domain.)url of iframe
beyond security problem?


If the iframe contains a document loaded from the same origin as the
parent document then script in the parent document can access
window.frames.anotherWorld.location.href
window.frames.anotherWorld.location.host
window.frames.anotherWorld.document.title

I am not sure what "beyond security problem" means, if you are looking
for ways to script such a document on a remote host with script from
your own document then on Windows instead of IE you could use HTA, HTML
applications as there your script is not subjected to the same origin
policy. Or you could write a Windows Script Host script to automate an
IE browser window into which you load that URL, that way your Windows
Script Host script has access to the objects IE exposes for the document.
With Mozilla/Netscape you don't need an HTA but could write your own
local HTML document referencing that external frame document and then
your script in the local HTML document is able to request privileges to
do stuff normally not allowed, e.g. access that frame. But that will
only work if your own HTML document is being loaded locally and the
browser users then in a dialog grants the script the privilege. If you
have a document on a HTTP server then you need signed script.
Here is an example, if you load that from the local file system in
Mozilla or Firefox then every time a document has been loaded in the
iframe the script requests the UniversalBrowserRead privilege for cross
domain scripting, so the browser will fire up a dialog asking the user
to grant or deny the privilege and if granted the script access the
iframe and its document:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>requesting privilege in Mozilla</title>
<script type="text/javascript">
function output (text, tagName, parentNode) {
tagName = tagName || 'p';
parentNode = parentNode || document.body;
var doc = parentNode.ownerDocument;
var element = doc.createElement(tagName);
element.appendChild(doc.createTextNode(text));
parentNode.appendChild(element);
}

function privilegeTest () {
if (typeof netscape != 'undefined' &&
typeof netscape.security != 'undefined' &&
typeof netscape.security.PrivilegeManager != 'undefined' &&
typeof netscape.security.PrivilegeManager.enablePrivilege !=
'undefined')
{
try {

netscape.security.PrivilegeManager.enablePrivilege ('UniversalBrowserRead');
try {
var frame = window.frames.remoteFrame;
output('location.href: ' + frame.location.href);
output('location.host: ' + frame.location.host);
output('title: ' + frame.document.title);
var p = frame.document.getElementsByTagName('p')[0];
if (p != null) {
p.appendChild(p.ownerDocument.createTextNode(
' Kibology for all. '));
}
}
catch (e1) {
output('Error ' + e.message);
}
}
catch (e) {
output('Privilege not granted: ' + (typeof e == 'string' ? e :
e.message));
}
}
}
</script>
</head>
<body>

<h1>privilege test</h1>

<div>
<iframe name="remoteFrame"
width="100%"
height="400"
onload="privilegeTest();"
src="http://www.mozilla.com/"></iframe>
</div>
</body>
</html>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 26 '05 #4

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

Similar topics

6
by: Charles Crume | last post by:
Hello; My index.htm page (www.charlescrumesoftware.com for those interested in looking) contains 3 frames (left = content, top right = logo, bottom right = navigation). This domain name is...
6
by: NoCopy na | last post by:
Using the following example: domiframetest.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html...
7
by: Scott M. | last post by:
How can I disable the cross-site scripting check for one particular page of a site?
4
by: taoberly | last post by:
Hello, Is it possible to run an HTML file from "localhost" and bypass the various security checks in place for cross-frame scripting? For example, on a 2-frame page loaded locally: a) frame...
1
by: WT | last post by:
Hello, I have an asp.net 1.1 application that runs an asp.net 2.0 page in an iframe. I need to save the contained app before saving the main one when the save button is clicked. For this I...
11
by: taoberly | last post by:
A few months ago I posted a question about using a file on my hard drive to perform cross-frame scripting and pull data from a server on my company's intranet. I eventually got this working using...
2
by: KZSteele | last post by:
hello - i am using VBA within a microsoft access project to automate internet explorer. what i am doing is reading data from various frames in the IE window and loading them into a table. ...
0
by: KZSteele | last post by:
(repost/edit from html forum) hello - i am using VBA within a microsoft access project to automate internet explorer. what i am doing is reading data from various frames of my company's web...
3
by: dotpranay | last post by:
Hi, I have two websites in my local IIS. Website A and B. A runs under SSL and B does not. A has a page that has an iframe showing B in that iframe. Both sites being on the same domain. i could...
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: 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:
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
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
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.