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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:50:06+00:00 2026-06-06T22:50:06+00:00

Is there a way to parse html content using javascript? I have a requirement

  • 0

Is there a way to parse html content using javascript?

I have a requirement to display only a div from some other site into my site. Is that possible? For example consider I want to show only div#leftcolumn of w3schools.com in my site. Is this even possible?

How can I do the same using javascript or jQuery?

Thanks.

  • 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-06T22:50:07+00:00Added an answer on June 6, 2026 at 10:50 pm

    You need to have a look at Same Origin Policy:

    In computing, the same origin policy
    is an important security concept for a
    number of browser-side programming
    languages, such as JavaScript. The
    policy permits scripts running on
    pages originating from the same site
    to access each other’s methods and
    properties with no specific
    restrictions, but prevents access to
    most methods and properties across
    pages on different sites.

    For you to be able to get data, it has to be:

    Same protocol and host

    You need to implement JSONP to workaround it.


    Though on same protocol and host, jQuery has load() function which you would use like this:

    $('#foo').load('somepage.html div#leftcolumn', function(){
      // loaded
    }); 
    

    Another possible solution (untested) would be to use server-side language and you don’t need jsonp. Here is an example with PHP.

    1) Create a php page named ajax.php and put following code in it:

    <?php
      $content = file_get_contents("http://w3schools.com");
      echo $content ? $content : '0'; 
    ?>
    

    2) On some page, put this code:

    $('#yourDiv').load('ajax.php div#leftcolumn', function(data){
        if (data !== '0') { /* loaded */ }
    }); 
    

    Make sure that:

    • you specify correct path to ajax.php file
    • you have allow_url_fopen turned on from php.ini.
    • your replace yourDiv with id of element you want to put the received content in
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PHP, is there a nice way to get the (parsed) introduction only from
Is there a direct way to parse an iCalendar date to .net using c#?
Is there any way in Python that would allow me to parse an HTML
Is there a way to check if jQuery is loaded using PHP? I have
I am using Beautiful Soup to extract 'content' from web pages. I know some
Is there a way to detect if someone is trying to parse your content
I'm interested in using pugixml to parse HTML documents, but HTML has some optional
I read some var from my HTML-Page using GWT Dictionary. The var looks like
Is there a way to parse a website's source on the iPhone to get
I've been wondering if there's a way to parse XML in Objective C as

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.