Skip to content

Instantly share code, notes, and snippets.

@moorthy-g
Created October 28, 2019 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moorthy-g/43ca258c3563566b13f65fee710f08bd to your computer and use it in GitHub Desktop.
Save moorthy-g/43ca258c3563566b13f65fee710f08bd to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<script>
const srcAssigner = () => {
const myframe = document.getElementById('myframe');
myframe.src = 'https://w3.org/about';
};
const srcReplacer = () => {
const myframe = document.getElementById('myframe');
myframe.contentWindow.location.replace('https://w3.org/about');
};
</script>
</head>
<body>
<div>
<iframe
id="myframe"
title="location"
src="https://w3.org"
width="600"
height="450"
frameBorder="0"
></iframe>
</div>
<button onclick="srcAssigner()">Assign Src</button>
<button onclick="srcReplacer()">Replace</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment