I have a problem of being unable to access data contained in the object corresponding to an <object>
-html element which is used to display another website. The use-case scenario is that I want to display external website within my page and I want to know on which links users click (within this integrated external website)
Specifically, I am interested in the URL or in the name of the document. When I try to get this data (which I can see when I browse through the object using firebug) I am unable to do it. Somehow access is restricted or I do something wrong.
Here is exactly what I am doing.
1) I define an object with a wikipedia article as a data source
<object id='wikiframe' data='http://en.wikipedia.org/wiki/thing' width='100%' height='700px'> Error: Embedded data could not be displayed. </object>
2) I define a click event for the document in order to know when user clicks
$(function() {
document.onclick = myClickHandler;
function myClickHandler() {
// Please help to assign a string with the wikipedia article name or with the string of url of the link which was clicked to the variable articleName;
var articleName;
var wikiObject = $("#wikiframe");
alert('The name of the currenttly opened wiki article is: ' + articleName);
}
});
Now here are the problems:
1) If I click within the article, click event does not fire.
2) I cannot access the data contained in the object corresponding to this element. But there is information I need in it as you see on the screenshot.
On the screenshot you see a wikipedia article which was opened by clicking on a link within the article which was first displayed. Firebug displays the information I need (in this case the URL to the article "Noumenon"
Link to image displaying the properties I want to access http://img856.imageshack.us/img856/3217/informationcontainedino.png
Can you please help by telling me what I need to add in order to assign articleName
a string with the url of the clicked link.
The whole code is here:
<!doctype html>
<html lang="en">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
If you click anywhere except the object click event fires. If you click on object it does not. I want the click event firing on clicking within wiki article and showing either a) the name of currently opened article OR b) the url of the clicked link
<object id='wikiframe' data='http://en.wikipedia.org/wiki/thing' width='100%' height='700px'> Error: Embedded data could not be displayed. </object>
</body>
<script>
$(function() {
document.onclick = myClickHandler;
function myClickHandler() {
// Please help to assign a string with the wikipedia article name to the variable articleName;
var articleName;
var wikiObject = $("#wikiframe");
alert('The name of the currenttly opened wiki article is: ' + articleName);
}
});
</script>
</html>