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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:45:05+00:00 2026-05-26T21:45:05+00:00

Using JQuery, I am loading a div from an external HTML page into fancybox

  • 0

Using JQuery, I am loading a div from an external HTML page into fancybox and am building the link using variables. It is taking two clicks to open it. The first, I believe, is only initiating it. But I don’t know how to fix it. Is there a better way to be doing this?

The HTML is here:

<a class="BannerVideoAwesome fancybox" id="series900" border="0"   href="/mkting/Videos/Speakers.html"><img src="/images/titles/CM/series-speakers-video.jpg" border="0"  align="left" /></a>

The jQuery is here:

$('a.BannerVideoAwesome').live('click', function(e){
    e.preventDefault();
    var url = $(this).attr('href');
    var grabVid = '#' + $(this).attr('id');
    vidObject = url + grabVid;
    var vidContents = vidObject.html();
    alert(vidContents);
    $.fancybox({
            //'href': url,
            'content':'vidContents'
                     });

Thank you so much in advance for any help someone can give me. I have been struggling with this for days.

  • 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-26T21:45:06+00:00Added an answer on May 26, 2026 at 9:45 pm

    I think the title of your post is a little bit misleading. Anyway, if I understood right, you just want to load a partial content (DIV) from an external html file into fancybox.
    In your example, the file episodeSpeakers.html contains a DIV with ID=’series900′

    <div id="series900">selected content</div>
    

    If the above is correct, then you don’t need to use jQuery live(), but binding fancybox to a click() and use ajax and dataFilter to select the content.

    With the same html, this script should do the trick:

    $("a.BannerVideoAwesome").click(function() {
    var grabVid = "#"+$(this).attr('id');
    $.fancybox(this,{
     'type': 'ajax',
     'ajax': {
       dataFilter: function(data) {
       var vidContents = $(data); 
       vidContents = $(grabVid, vidContents); 
       return(vidContents); 
      } // datafilter
     } // ajax
    }); // fancybox
    return false;
    }); //click
    

    or you may use

    $("a.BannerVideoAwesome").click(function(event) {
    event.preventDefault();
    .
    .
    

    instead of

    return false;
    

    IMPORTANT : Due to some cross-browser issues, don’t use the dataFilter solution above.
    It would be better to use the fancybox’s inline method, adding the partial content (from the external html file) into a hidden DIV within your calling html document and then move it from there into fancybox. It requires (of course) to add such DIV. e.g.:

    <div style="display: none;">
     <div id="fancyContent"></div>
    </div>
    

    Then use this script:

    $("a.BannerVideoAwesome").click(function() {
    var grabVid = "#"+$(this).attr('id');
    $.ajax({
     type: "GET", // default
     dataType: "html",      
     cache: false,                      
     url: this.href,
     success: function (data) {
      $("#fancyContent").html(grabVid ? $("<div>").append(data).find(grabVid) : data);
      $.fancybox({
       'href': "#fancyContent",
       'onCleanup': function() {
         var fancyContent = this.href;
         $(fancyContent).unwrap().empty();
       } // onCleanup 
      }); // fancybox
     } // success
    }); //ajax
    return false;
    }); //click
    

    that works on most browsers.
    BTW, the onCleanup option fixes this bug

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

Sidebar

Related Questions

i'm loading, using the JQuery ajax() method, an external page with both html and
I am loading data from external html files within my domain into a div
I'm loading some some html into a div through ajax using jquery. Once the
I am loading an aspx page into a div using jquery.load(). The aspx page
Is it possible to load content from an external page (not relative) into div
I have a simple html page with a div. I am using jQuery to
I'm currently loading a view(ascx) into a div using jQuery load(). I want to
I am having issues with loading external javascript using JQuery. Every time when I
I am loading feed-items into a ul using this jQuery .ajax() call, which I
I'm loading a page containing a GMaps using the ajax() method of jQuery. The

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.