我有一个iframe,需要捕获javascript变量中的src属性。这就是我的iframe看起来像从iframe中获取iframe src参数
<iframe id="iframe_module_46081" name="iframe_module_46081" src="//myurl.com/tabs/495/campaigns/0ed3ffa8-5050-4a18-a5e3-f348d12a1304?signature=6aa3005368f163539976460246f2f0839c0fb3e3&id=678326">
<script>$(document).ready(function(){
var name = window.name;
var src = ????;
})
</script>
</iframe>
我能够通过window.name而不是src属性获取名称。任何想法?
'top.document.getElementsByName(window.name)[0] .src'应该这样做 – 2012-04-19 15:48:35
@GGG:这不适用于跨域。 – SLaks 2012-04-19 15:49:14
@SLaks显然,除了'document.location'之外,什么都不会工作跨域= /但我认为由于某种原因他不适合他。 – 2012-04-19 15:50:15