无法访问元素(Javascript\jQuery)的URL属性

无法访问元素(Javascript\jQuery)的URL属性,javascript,jquery,frame,html-object,Javascript,Jquery,Frame,Html Object,我有一个问题,就是无法访问与用于显示另一个网站的-html元素对应的对象中包含的数据。用例场景是,我想在我的页面中显示外部网站,我想知道用户在这个集成的外部网站中单击哪些链接 具体来说,我对URL或文档的名称感兴趣。当我试图获取这些数据时,当我使用firebug浏览对象时,我无法做到这一点。不知怎的,访问被限制了,或者我做错了什么 这正是我正在做的 1我使用wikipedia文章定义一个对象作为数据源 <object id='wikiframe' data='http://en.wikip

我有一个问题,就是无法访问与用于显示另一个网站的-html元素对应的对象中包含的数据。用例场景是,我想在我的页面中显示外部网站,我想知道用户在这个集成的外部网站中单击哪些链接

具体来说,我对URL或文档的名称感兴趣。当我试图获取这些数据时,当我使用firebug浏览对象时,我无法做到这一点。不知怎的,访问被限制了,或者我做错了什么

这正是我正在做的

1我使用wikipedia文章定义一个对象作为数据源

<object id='wikiframe' data='http://en.wikipedia.org/wiki/thing' width='100%' height='700px'> Error: Embedded data could not be displayed. </object>
下面是问题:

1如果我在文章中单击,则单击事件不会触发。 2我无法访问与此元素对应的对象中包含的数据。但正如你在截图上看到的,我需要一些信息

在屏幕截图上,您可以看到一篇维基百科文章,该文章是通过单击第一次显示的文章中的链接打开的。Firebug显示了我在本例中需要的信息—文章本体的URL

你能告诉我我需要添加什么来为articleName分配一个带有点击链接url的字符串吗

整个代码如下:

<!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>

事实上,您不能这样做是因为。如果数据在那里,并且浏览器也可以访问它,那么必须有一种方法来访问它。尝试理解为什么您不能这样做:var datalink=$'wikiframe'。attr'data'@詹姆斯·戴利:这是我的第一个想法,它适用于URL,但不适用于任何文档属性(如标题)。@詹姆斯·戴利:这是我的第一个想法。但如果你这样做,你将永远得到原始值。只要您通过单击链接来更改页面内容,document.URI就会更改,但不会更改数据属性。
<!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>