gpt4 book ai didi

javascript - 更改 iframe src

转载 作者:行者123 更新时间:2023-11-30 13:15:07 25 4
gpt4 key购买 nike

例如我在 index.html 中有一些链接:

<a href="message.html">Go to message page</a>

在其他页面,iframe.html 我有一个iframe:

<iframe id="iframe" src="profile.html" frameborder="0" scrolling="no"></iframe>

是否可以这样做,以便在我单击“转到消息页面”链接时将我重定向到 iframe.html 并将 iframe src 更改为 message.html?

最佳答案

一个简单的解决方案:

index.html 中的链接应该如下所示:

<a href="iframe.html?message.html">Go to message page</a>

iframe.html 中做这样的事情:

$(function () {
var url = window.location.href;
var QueryStr = url.split('?')[1];
$('#iframe').attr('src', QueryStr);
});

希望这将是您的答案。谢谢!

SEE DEMO

查看页面:

关于javascript - 更改 iframe src,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12293882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com