471,321 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,321 software developers and data experts.

cross frame scripting

<title>Cross Frame Reference</title>
<script language="javascript">
function showThisTitle() {
function showAnotherTitle() {
try {
catch (e) {
<iframe width="100%" height="50%" name="anotherWorld"
<div align="center">
<input type="button" value="Show this title"
<input type="button" value="Show iframe's title"

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 10084
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.

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.


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

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"
<html lang="en">
<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);

function privilegeTest () {
if (typeof netscape != 'undefined' &&
typeof netscape.security != 'undefined' &&
typeof netscape.security.PrivilegeManager != 'undefined' &&
typeof netscape.security.PrivilegeManager.enablePrivilege !=
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) {
' Kibology for all. '));
catch (e1) {
output('Error ' + e.message);
catch (e) {
output('Privilege not granted: ' + (typeof e == 'string' ? e :

<h1>privilege test</h1>

<iframe name="remoteFrame"


Martin Honnen
Dec 26 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Charles Crume | last post: by
7 posts views Thread by Scott M. | last post: by
4 posts views Thread by taoberly | last post: by
1 post views Thread by WT | last post: by
11 posts views Thread by taoberly | last post: by
reply views Thread by rosydwin | last post: by

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.