Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9258261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:21:11+00:00 2026-06-18T12:21:11+00:00

I have an iframe in my web page. I modify the src property via

  • 0

I have an iframe in my web page. I modify the src property via javascript like so:

document.getElementById('myiframe').src = 'http://vimeo.com/videoid1';
document.getElementById('myiframe').src = 'http://vimeo.com/videoid2';
document.getElementById('myiframe').src = 'http://vimeo.com/videoid3';

However, everytime I do this, it’s logged into the browser’s history. So everytime I press back in the browser window, the iframe content goes from videoid3 to videoid2 to videoid1. If I press back again, the entire page goes back.

I would like to modify the iframe src with javascript WITHOUT logging an entry into the browser’s history. So if i click the browser back button, the entire page goes back without updating the iframe.

I tried doing something like:

document.getElementById('myiframe').contentWindow.location.replace('http://vimeo.com/videoid1');
document.getElementById('myiframe').contentWindow.location.replace('http://vimeo.com/videoid2');
document.getElementById('myiframe').contentWindow.location.replace('http://vimeo.com/videoid3');

Although this made the browser back button behave the way I wanted to, it broke certain things in the vimeo video. Vimeo REQUIRES you to change urls via the iframe.src instead of contentWindow.location.replace().

As such, how do I modify the iframe.src WITHOUT logging into history?

Related
This is actually one of the solutions I’m exploring to solve the main problem, which I posted here History object back button with iframes

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:21:12+00:00Added an answer on June 18, 2026 at 12:21 pm

    don’t change the src, just replace the old iframe with a new one?

    const urls = [
      "http://bing.com",
      "http://google.com",
      "http://duckduckgo.com"
    ];
    
    function next() {
      if(urls.length==0) return;
      const original = document.getElementsByTagName("iframe")[0];
      const newFrame = document.createElement("iframe");
      newFrame.src = urls.pop();
      original.parentNode.replaceChild(newFrame, original);
    }
    
    nextbtn.addEventListener("click", () => next());
    iframe {
      width: 300px;
      height:300px;
    }
    <p>let's test some iframes</p>
    <button id="nextbtn">next</button>
      <iframe />

    No history states. Same functionality. Everyone wins.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page on http ://localhost/mySite/Page1.aspx that contains an iframe with src
http://www.escapingaspinningroom.com/photos/photo/193 is a web page where I have the comment iFrame on. Litteraly, the
I have a web page with an iframe in it (I don't like it,
I have an iframe where the web page inside of the iframe runs a
I have an iframe in the same domain as the web page. I have
I have a web page into a html iframe, the web page has a
I have an iframe that looks like this: <iframe id=iframe2 ...> #document <html>...</html> </iframe>
I have a web page that has a DIV and an IFRAME. When a
I have a web page that I would like others to add onto their
In my web page I have an iframe that displays another page. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.