简体   繁体   中英

How to include HTML/text file without ajax call or server side language

Background information :

A tool simulates IE behavior, instead of HTML for browser, it uses a special object which contains html segment <![CDATA[ HTML Here or JS here ]]> . The tool disabled the ajax call ; however, the activeX works on that tool. In other words, HTML display in browser = special object display. No server side language (ie php) allowed.

Problem :

The object developed for that tool contains everything(html+css+js) in one single file. Then it makes developer difficult to manage changes. Currently, when I develop, I copied the HTML from <![CDATA[ All HTML or JS here ]]> ; after I modified it , I copied the html file back to <![CDATA[ HTML Here or JS here ]]> . I want the object is more organized, for example: in the html segment of the object, just put something like <![CDATA[<javascript>require a.html<javascript> ]]> , then the content in a.html will be automatically placed in the object. Can you suggest any solution or any library for this problem?

ps: I didn't use requirejs before, it seems requirejs uses ajax call to include text file, is it possible that requirejs uses local path to include a file?

Thank you.


Partial solution to my problem: I used activeX to read the entire file, and used jQuery to set the file content to some html element. so the js will look like:

<![CDATA[ <script>var k = readfile(getAbsolutePath()+"\\\\a.html"); jQuery("#display").html(k);<script> ]]>

I think this solution is for my tool only; To make it work, some requirements: 1. can get the absolute path of the text/html file. 2. activeX works.

OK, now that I understood your problem.

Use

<iframe src="another_file.html">

That is probably the only way to load multiple html files without Ajax or PHP, as far as I know.

根据prytsh的评论,使用嵌入调用应该可以解决HTML5的问题:

You can try this by using jquery

//use this line in jquery  
$("#id").load("trackingCode.html");

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