1

I will try to summarize the best I can what I need and what is blocking me to do it.

What I need

I need to append script tags to the head of an html file, BUT during my "build" process. I'm using ant as a automation build tool, and I would like to avoid placing tokens in my HTML file to then replace it with ant, or also I will like to avoid any midway solution using regular expression matching. Waht I would really like to use is plain javascript running through rhino javascript interpreter and exceute it easily from an ant task, and finally add the script tag dinamically.

What is blocking me?

I really don't know anyway that I can load an html file without issuing a GET or a POST HTTP methods. Cause I'm building my code from source I don't have it under an HTTP server, so I wish I could find someway to load the HTML DOM into a javascript variable and then write it with the new script tag that I need.

I need all the DOM manipulation features without having a browser that renders the HTML file.

Best! Demian

Michael Mior
  • 28,107
  • 9
  • 89
  • 113
denica
  • 221
  • 1
  • 3
  • 12
  • 3
    You you give an example (in code or some sort of pseudocode) of exactly what you're trying to do? It's not clear from the question. – Michael Mior May 04 '12 at 17:13
  • Try this http://api.jquery.com/load/, I only read your question's title though. – KBN May 04 '12 at 17:21
  • I'm sorry @MichaelMior, I'm just thinking how could I approach a solution. I don't have any code yet :(. But in order to clarify more, I have one html file and a javascript file (supose under the same path). What I will like to do is some sort of $.load(foo.html) to build the DOM object but I don't have foo.html under an http server. I would like to load it using only the file path (not an XHR). – denica May 04 '12 at 17:50

1 Answers1

1

From what I understand you would like to have a valid DOM object from an HTML file, as if you were running in a browser, but do it "offline"? e.g. be able to do a jQuery selector on the DOM and edit it?

This will allow you to do DOM traversing and modifications without a browser as far as I understand

Community
  • 1
  • 1
Eran Medan
  • 44,555
  • 61
  • 184
  • 276
  • Hi Eran, thanks a lot for your answer :). Yes, you understood me well, I need to have all the DOM manipulation features without a browser that renders my html file upfront. I will research how could I dot it from node. Thanks! – denica May 04 '12 at 17:39