【发布时间】:2014-11-09 21:53:01
【问题描述】:
我有一个带有广告 (A) 的主页。单击广告 (A) 应打开包含“iframe”的页面 (B),并且 I 框架应显示 html 文章页面 (C)。页面(B)中的这个iframe用于打开很多文章,但我不知道如何使用HREF或ONCLICK定位特定的文章?请帮忙。
【问题讨论】:
标签: javascript html iframe targeting
我有一个带有广告 (A) 的主页。单击广告 (A) 应打开包含“iframe”的页面 (B),并且 I 框架应显示 html 文章页面 (C)。页面(B)中的这个iframe用于打开很多文章,但我不知道如何使用HREF或ONCLICK定位特定的文章?请帮忙。
【问题讨论】:
标签: javascript html iframe targeting
A.html:
<a target="_blank" href="B.html?go=C.html">my ad</a>
B.html:
<script>
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
document.write('<iframe src="' + getParameterByName("go") + '"></iframe>');
</script>
C.html:
lorem ipsum dolar sit amet
【讨论】: