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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:48:47+00:00 2026-06-07T14:48:47+00:00

I have the following jQuery code which doesn’t seem to be doing anything. When

  • 0

I have the following jQuery code which doesn’t seem to be doing anything. When the link is clicked, I’m trying to get the value of its url attribute to be copied into the iframe‘s src attribute.

Basically this is supposed to make links open up in an iframe (the content of the iframe is replaced every time a new link is clicked) instead of acting like normal links.

So what is wrong with my code?

$('p.tweet a').click(function(){
    var link = $(this).attr('url');
    $('iframe').attr('src',link);
})
  • 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-07T14:48:53+00:00Added an answer on June 7, 2026 at 2:48 pm

    So what is wrong with my code?

    You are not canceling the default action by returning false from the click handler of the anchor you subscribed to and thus not leaving any chance for your script to execute before the browser simply redirects away from that page:

    $('p.tweet a').click(function() {
        var link = $(this).attr('href');
        $('iframe').attr('src', link);
        return false;
    });
    

    And by the way notice that I’ve used $(this).attr('href') instead of $(this).attr('url'). The href attribute is kinda more common to anchors than the url attribute in standard HTML, but if you have invented some markup in which anchors have an url attribute then you could give it a spin.

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

Sidebar

Related Questions

I have the following jquery code which doesn't work quite right when trying to
I have the following jQuery code which runs when I'm clicking an option in
I have the following jQuery code: $(body.page-calendar-practices-2012-05 #content-header h1#title) which works fine. I can
I have the following JavaScript code which I like to convert to jQuery but
I have the following code alternatives, neither of which is satisfactory. I'm using jQuery
I have the following Code which I know doesn't work correctly. Yes I know
I have the following code in jQuery for a set of radio buttons which
In my jquery i have the following code, which for some reason is not
I have a problem with the following code, which doesn't want to work in
I have the following code and it doesn't seem to work at all. No

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.