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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:40:11+00:00 2026-06-14T10:40:11+00:00

I looked around here and found this script to reference a parent from an

  • 0

I looked around here and found this script to reference a parent from an iframe:

$(parent.document.body)

But how would I right a script that says, if the body of the parent has a certain class,
make a link within my iframe go to a certain destination?

My iframe lives on the same server as the parent. I’m using this script once the parent body.class is defined:

$("#some-link").attr('href','entrant-list.html');

Just to be clear – my script lives in iframe, looks for class in parent doc, then sets a url on an element within iframe based on what class it found in parent doc.

Just need some help with the final code. Thank you.

  • 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-14T10:40:12+00:00Added an answer on June 14, 2026 at 10:40 am

    in your iframe, have an onready script that does the following:

    $(function(){
        var pBody = $(parent.document).find("body")
        if(pBody.hasClass("foo")){
            $("#some-link").attr("href", "bar.com");
        } else if(pBody.hasClass("foo2")){
            $("#some-link").attr("href", "bar2.com");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked around here and the Internet in general but it seems this
I looked around but haven't found an answer to this. I have a CentOS
I've looked around here for similar question but couldn't find any that solved my
I looked around and couldn't find it! Maybe I didn't look hard enough,but this
I looked around and found that there is an onerror function for flexigrid but
I have looked around here to see if somebody has asked this question before
I've looked around a bunch and found the itertools pacakge, but as far as
I've looked around for some time and have not found anything like this, I
Sorry if this has been asked somewhere else, but I have looked all around,
I've looked around at pretty much all the SMS posts here on SO and

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.