Skip to content

Instantly share code, notes, and snippets.

@saiday
Created June 3, 2024 05:47
Show Gist options
  • Save saiday/f9b27c3e6eb438297c55a57b8a4a5e69 to your computer and use it in GitHub Desktop.
Save saiday/f9b27c3e6eb438297c55a57b8a4a5e69 to your computer and use it in GitHub Desktop.
pseudo code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>URL Manipulation Example</title>
<script>
document.addEventListener('DOMContentLoaded', () => {
// Assuming URL A is 'http://example.com/pageA' and URL B is 'http://example.com/pageB'
// Step 1: Load content from URL B (this can be done via AJAX)
fetch('http://example.com/pageB')
.then(response => response.text())
.then(data => {
// Step 2: Insert the content of URL B into a container
document.getElementById('content').innerHTML = data;
// Step 3: Modify the URL back to URL A
history.pushState({}, 'Page A', '/pageA');
})
.catch(error => console.error('Error loading URL B:', error));
});
</script>
</head>
<body>
<div id="content">
<!-- Content from URL A will be replaced with content from URL B -->
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment