像这样在查询字符串中发送您的目标页面
$('a[href="message.html"]').click(function (e) {
e.preventDefault()
window.location = 'iframe.html?src="message.html"';
})
在 iframe.html 上执行此操作
$(function () {
$('#iframe').attr('src', getParameterByName('src'));
});
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}