-2

I have been looking for two days a solution, without success, to display a DIV tag from one site to another.

My source website is on a server and I need to display a DIV on a local page.

i don't want to use iframe because I have to target only one text present on the source website.

Is the any solution with Java/Jquery/Html5 ?

Big thanks all :-)

Always Helping
  • 14,316
  • 4
  • 13
  • 29
MrMarty
  • 19
  • 5

1 Answers1

2

You can use jQuery's .load(), and bypass CORS using a service like CORS Everywhere.

Working demo:

var url = 'https://stackoverflow.com/q/62613919/1913729',
    selector = 'h1:first';
    
var corsUrl = 'https://cors-everywhere.herokuapp.com/' + url;

$('#result').load(corsUrl + ' ' + selector);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="result">Loading...</div>

If you don't want to use jQuery, you can use this solution by gurvinder372

blex
  • 24,941
  • 5
  • 39
  • 72