1

我有一个在 perl 中运行的遗留应用程序。我用一个 default.aspx 开发了一个 MVC 应用程序。在 default.aspx 中,我放置了一个母版页和一个 iframe 来打开旧版应用程序 url。我想要做的是每次,iframe 尝试导航到下一页(我的意思是,在 iframe 内),我想在我的 default.aspx 中捕获 url 并将查询字符串添加到 iframe 的 src

例子:

在旧版应用程序中,第一页是 http://iframe.com/index.cgi。单击 index.cgi 中的链接,它转到 http://iframe.com/product.cgi

在我的 MVC 应用程序中,我将在 iframe 中打开“http://iframe.com/index.cgi?MyQueryString”。当我们点击 index.cgi 中的链接时,根据旧版应用程序,它将尝试移动到 http://iframe.com/product.cgi。但我想让它“http://iframe.com/product.cgi?MyQueryString”


知道如何实现这一目标吗?

PS 我不允许更改旧版 perl 应用程序中的任何内容。我所能做的应该只在 Default.aspx 中完成

4

1 回答 1

0

我唯一能想到的就是做这样的事情:

<iframe id="perlIframe" src="http://yourPerlURLhere" onload="recordMe(this)"></iframe>​

然后,您每次iframe加载新页面时都可以像这样抓取src或排序:location.href

function recordMe(a){    
    console.log(a.src);

或者

    console.log(a.location.href);

但是,如果这两个页面不在同一个域中,您最终会遇到一些“同源”问题。

于 2012-10-08T21:41:07.823 回答