【问题标题】:How to check if user is in a specific site within an <object> navigator in your site如何检查用户是否在站点的 <object> 导航器中的特定站点中
【发布时间】:2011-05-20 02:33:53
【问题描述】:

我有一个包含此代码的网页:

<object data=http://<?php echo $_GET['wp'];?> width="600" height="400"> <embed src=http://<?php echo $_GET['wp'];?> width="600" height="400"> </embed> Error: Embedded data could not be displayed. </object>

我想知道用户是否通过导航设法到达

<object>.

这可能吗?

如果没有,是否有另一种方法可以在网站中嵌入网页,让我知道他在哪个网页中?

编辑:如果我们知道目标页面的源代码的一些上下文,我们只需要查看页面内的页面是否包含这部分代码,这可能吗?

【问题讨论】:

    标签: html web object embed


    【解决方案1】:

    你可以使用 iframe!

    var url =
       document.getElementById('my-iframe').src;
    

    编辑:正如 Ant 所提到的,除非iframe 中页面的域与包含iframe 的页面匹配,否则您无法从iframe 标记中获取网址。

    【讨论】:

    • 好主意,但我需要更多帮助...我将代码更改为:&lt;iframe name="site" frameborder="0" height="1000" src="http://&lt;?php echo $_GET['wp'];?&gt;"target="_blank" width="620" scrolling="Auto";&gt; &lt;/iframe&gt; 并尝试了这个:&lt;script type="text/javascript"&gt; function currentpage() { alert(document.getElementById('site').contentWindow.location.href); } &lt;/script&gt; ...&lt;form&gt; &lt;input type="button" value="Click me!" onclick="currentpage()" /&gt; &lt;/form&gt; 但是当我单击按钮时什么都没有发生
    • 您需要将id 属性添加到&lt;iframe&gt; 标签。您正在使用 name 属性。
    • 我刚找到这个问题,似乎提供了答案:stackoverflow.com/questions/44359/…
    • 所以,除非用户在同一域中导航,否则似乎不可能,&lt;iframe&gt; 是...无论如何,非常感谢您提示我应该研究什么...跨度>
    猜你喜欢
    • 1970-01-01
    • 2011-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-15
    相关资源
    最近更新 更多