Javascript 使用另一个网页中的按钮更改一个网页中的div
我有两个网页:一个像电视,另一个像遥控器 这是电视Javascript 使用另一个网页中的按钮更改一个网页中的div,javascript,jquery,html,ajax,Javascript,Jquery,Html,Ajax,我有两个网页:一个像电视,另一个像遥控器 这是电视 <!DOCTYPE html> <html> <head> <title>Welcome to RemoteDemo</title> </head> <body> <div id="Tvspace"> <iframe width="560" height="315" src="SomeRa
<!DOCTYPE html>
<html>
<head>
<title>Welcome to RemoteDemo</title>
</head>
<body>
<div id="Tvspace">
<iframe width="560" height="315" src="SomeRandomYoutubeURL" frameborder="0" allowfullscreen></iframe>
</div>
</body>
</html>
我希望它在不刷新或创建新页面的情况下加载内容。谢谢。他们在信中说:
window.location对象可用于获取当前页面地址
URL和以将浏览器重定向到新页面
因此,不能使用窗口位置加载iframe。您可以使用它获取页面的url,并将其设置为重定向到其他页面
如果选中此项,您可以找到一种方法,用另一个url加载iframe:
$("#next").on('click', function(){
$("#Tvspace iframe").attr("src", "http://www.google.com/");
});
这两页到底有什么关系?从你的问题中我只能看到两页,其中一页包含一个iframe。它们在同一个文件夹@Taplar中
$("#next").on('click', function(){
window.location = "http://www.google.com/";
});
$("#next").on('click', function(){
$("#Tvspace iframe").attr("src", "http://www.google.com/");
});