大佬教程收集整理的这篇文章主要介绍了将javascript值传递到iframe标记,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
对广告服务器的请求通常需要每个站点声明一次的种子变量,并且每次客户端加载页面时都会递增.我想要做的是将种子变量传递到我的iframe部分调用的文档中.
种子变量在我的主html文档的’head’标签中初始化:
<head> <script type="text/javascript"> <!-- custom_seed=1; //--> </script> </head>
稍后在html文档中,我通过iframe发出请求,iframe返回调用广告服务器所需的html.
<body> <!-- a bunch of html to display the page --> <iframe src="somepage.html" width="100%" height="100%"> <p>No support for iframe</p> </iframe> </body>
‘somepage.html’中返回的html有一个用于调用广告服务器的脚本,需要使用先前声明的种子变量作为参数:
<script type="text/javascript"> document.write('<script type="text/javascript" src="http://ad.server.net/...seed='+ custom_seed +'?"></script>'); custom_seed++; </script>
有什么好办法实现这个目标?
主要文件:
document.getElementById('IframEID').src = "somepage.html?seed=" + custom_seed;
内部文件:
var seed = window.LOCATIOn.search.subString(window.LOCATIOn.search.indexOf('seed=') + 5); if (seed.indexOf('&') >= 0) { seed = seed.subString(0,seed.indexOf('&')); }
以上是大佬教程为你收集整理的将javascript值传递到iframe标记全部内容,希望文章能够帮你解决将javascript值传递到iframe标记所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。