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 3962264
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:04:32+00:00 2026-05-20T03:04:32+00:00

I have an iframe and i would like to make an if condition that

  • 0

I have an iframe and i would like to make an if condition that if the iframe source is equal to a speciefied page a div should show:

Example

if(getElementById('iframe').src = 'someurl'){
getElementById('div').style.display. = 'block';
}

The Problem

I am not an expert in JS but when I use this script the iframe loads “someurl” automatically asoon as the main page is loaded, which I don’t want, I want the div to be displayed when the iframe source changes to “someurl” via a link. The link is working fine and it changes the iframe src but the if statement isn’t working.

  • 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-05-20T03:04:33+00:00Added an answer on May 20, 2026 at 3:04 am
    • = is an assignment
    • == is an equality test
    • === is an equality test without type casting (and is generally prefered to ==

    Use ===, not =.

    Then you need to reference getElementById correctly. It is a method of the document object, not a global.

    Use document.getElementById not getElementById

    Then, you’ll need to get rid of the trailing . character from your display property.

    Then, assuming you want to update this when a link in the frame is followed and not just when a link in the current page is followed, you need to rerun the function periodically to see if it has changed.

    setInterval(yourFunctionName, 5000); 
    

    Then, since the page might move away from the URL you are looking for, you need to add an else statement

    function yourFunctionName () {
        var div = document.getElementById('div'); /* Really? Your unique ID for a specific div is 'div'?! */
        if(document.getElementById('iframe').src === 'someurl'){
            div.style.display = 'block';
        } else {
          div.style.display = 'none';
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iframe that loads a page that I would like to disable
I have an iframe that loads a page that I would like to disable
I have a web page that I would like others to add onto their
I would like to have an iframe take as much vertical space as it
I have an IFrame app, and I would like to use some Connect features
I would like to make my iframe fadein as soon as the visitor has
I would like to create an <iframe> on the page, but then add the
I have an iframe loaded with some content. I would like to move it
I have an iframe for which I would like to enable a horizontal scroll
I would like to make a facebook page tab with a form field, where

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.