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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:14:16+00:00 2026-06-02T11:14:16+00:00

If I have two iframes, how can I match the one that HAS NOT

  • 0

If I have two iframes, how can I match the one that HAS NOT a youtube src ?

<iframe  src="http://googleads.g.doubleclick.net/pagead/ads?client=ca-feed-pub"></iframe>
<iframe  src="http://www.youtube.com/embed/Y4MnpzG5Sqc?wmode=opaque"></iframe>
  • 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-02T11:14:22+00:00Added an answer on June 2, 2026 at 11:14 am

    You have all your data in a single string, that may contain several tags? In that case you’ll need to 1) find each separate iframe in string, 2) check each found iframe if you need to remove it or leave it alone. Here’s the code that does just that with comments showing where each step is performed:

    var string='<iframe  src="http://googleads.g.doubleclick.net/pagead/ads?client=ca-feed-pub"></iframe><iframe  src="http://www.youtube.com/embed/Y4MnpzG5Sqc?wmode=opaque"></iframe><iframe  src="http://googleads.g.doubleclick.net/pagead/ads?client=ca-feed-pub"></iframe><some_good_tag>TEST</some_good_tag><iframe  src="http://www.youtube.com/embed/Y4MnpzG5Sqc?wmode=opaque"></iframe>'
    
    function filter_iframe(iframe_tag){
        // if iframe have youtube in it - return it back unchanged
        if(/src=".+youtube/.test(iframe_tag)){ return iframe_tag }
        // if not - replace it with empty string, effectively removing it
        return ''
    }
    
    // first, find each iframe in string and call function to check if you need to remove it
    var filtered=string.replace(/(<iframe.*?>.*?<\/iframe>)/g, filter_iframe)
    
    console.log(filtered)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two html files, one contains the other with an iframe, and I
I have a web page that contains two textboxes and a button. I can't
I have a GWT application that features two frames (com.google.gwt.user.client.ui.Frame). Via Frame.setUrl(...) I can
I have a button that loads two different pages in two iframes. I need
I have two div elements, one is the left panel, that is hidden, and
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two classes (MVC view model) which inherits from one abstract base class.
I have two files client.php and server.php. The client file send a HTTP request
I have two columns say Main and Sub . (they can be of same
I have two queries that find both the Zip codes, and the States for

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.