简体   繁体   中英

replace complete HTML file content from javascript

I have a html file under my war folder in the project, I just want to access that file From the path "/myhtml.html" and then replace whatever is in this file from a new text "Some new Text"

so that My html file now will only have "some new text" there.

I searched alot for this, but they provide example for changing a specific div etc in a file, but i just want to replace everything in a file which is present under a war folder.

I understand that you are trying to change the content of HTML files using Javascript that is running in the browser.

Front-end Javascript can't access local files that are stored on your machine. It would be a security disaster if it could. The only way Javascript can read with local files is using a file upload input, and it will only be able to read the files not update/overwrite them.

NodeJS however is capable of accessing the local file system. NodeJs is backend JavaScript so it will be running on a server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM