javascript - How to load an external HTML file -
i have html follows:
select file : <input type="file"><br><br> html codes : <textarea id="displayhtml"></textarea><br><br> <div id="displaypage">display html page here</div>
now how browse external html file local hard drive , display page preview in div #displaypage
, html tags of file textarea #displayhtml
? have no idea how please help.
my fiddle here: https://jsfiddle.net/zm6ga2ev/1/
you .load
other page content div.
//load full document $('#displaypage').load('http://same-domain.com/next-page.html'); // can use css selector load part of page $('#displaypage').load('http://same-domain.com/next-page.html #some-inner-id > *');
if #displaypage
element not found in dom, no request performed! if #some-inner-id
not found in request page dom, empty content.
note
loaded page must allow cross-origin request (usually means same domain request). here cross-origin requests.
Comments
Post a Comment