/    Sign up×
Community /Pin to ProfileBookmark

Access the Document object from another Frame (or iFrame)

Hello:

We are trying to analize the content of a web page using the document object.

The porpuse is to load a web page a get the links list and the url list.

This is the code we are using:
[CODE]<html>
<head>
</head>
<script>
function whenLoaded(){
f = top.frames[0].document;

numlinks= f.links.length;
alert(numlinks);
}
</script>
<FRAMESET cols=”50%,*” onload=”whenLoaded()” >
<FRAME bordercolor=”#CCCCCC” src=”http://www.google.es”>
<FRAME bordercolor=”#CCCCCC” src=”./hiden.html”>
</FRAMESET>

</html>
[/CODE]

The problem we face is a Javascript Error on line 6:

[CODE]
Line: 6
Char: 3
Error: Access denied
Code: 0
URL: [url]http://localhost:8080/Test.html[/url]
[/CODE]

It seems we are breaking some security protecction, accessing the document object for another server.
Here are the questions:
Can we disable this security check (perform by the browser, we supose) ?
Is there any other way to get this information (the links array) ?

Thanks in advance.

gonzalo floria (Madrid)

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisApr 22.2004 — [b]Can we disable this security check (perform by the browser, we supose) ? [/b][/quote]No.[b]

Is there any other way to get this information (the links array) ?[/b]
[/quote]
No. You can only get information from files on the same server. It is a security issue.
Copy linkTweet thisAlerts:
@gonso75authorApr 23.2004 — Well, i've manage to solve this problem but only for netscape browser.

I used this line:
[CODE]netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");[/CODE]
If the script is not signed, a dialog will appear asking the user to allow this security policy modification. If the user agrees, document object on another frame can be read.

GREAT!

Now, How can i do this on Internet Explorer? ?
×

Success!

Help @gonso75 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...