Maison > Questions et réponses > le corps du texte
Comme le montre l'image, comment utiliser js sur la page B pour contrôler la page A afin d'accéder à une certaine adresse ?
仅有的幸福2017-06-23 09:13:55
S'il est de la même origine, juste window.parent.location.href
c'est bien.
S'il y a différentes sources et aucun contrôle sur la page A, il n'y a pas de solution.
三叔2017-06-23 09:13:55
Dans les js de la page Bwindow.parent.window.location.href = '//www.baidu.com'
给我你的怀抱2017-06-23 09:13:55
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
</head>
<body>
<iframe src="b.html"></iframe>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<script type="text/javascript">
function parentJump() {
window.parent.location.href = 'http://www.baidu.com/';
}
</script>
</head>
<body>
<button onclick="parentJump();">父页面跳到百度</button>
</body>
</html>
Utilisez window.parent
pour accéder au formulaire parent à partir d'une page dans une iframe.