Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get back the clicked link from an iFrame

Status
Not open for further replies.

JulienBoyreau

Programmer
Mar 31, 2008
3
0
0
FR
Hello everyone,

I am writing a javascript hosted locally by my Firefox (I turned on privileges to write on the disk...)
On the HTML UI, I have a simple <input> and an <iframe>.
When I type an url into an <input>, the web page for this url is loaded into an <iframe>.

When I click a link into the <iframe>, I would like to get back the href of the clicked link as an argument for a function that's outside of the <iframe>.

I succeeded in reading the href from inside the <iframe> (by adding events in the loaded web page) but don't know how to get this string back into the main script?

Does anybody know how to do that?

Thanks for your help,

J.
 
onclick="top.yourFunctionName(this.href)"

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
Hi Dwarf,

thanks for the tip but I cannot get the result back;
I tried to paste the try/catch loop to get the privilege into the onclick and I got a "permission denied".

Any other idea to break this denial?

thanks

J.
 
Permission denied sounds like you're attempting cross-domain scripting which is prevented by the browser's security model.

Are both your container page and the page in your iframe coming from the same domain?

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
Hi Dwarf,

Actually no: my container is a local web page on my computer (file:\\\...) and in the iframe I would like to have any page, like one from Wikipedia.

If I follow you, even if I push the requirement to get the privilege from the page in the iframe, Firefox will forbid it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top