Hope this is in the right place.. When I use this I get the title from the html file, but I need to grab the entire html can anyone steer me in the correct direction. TitleFromHTML = ie.document.title The ie. of course mean internet explorer. Here is some of the things I tried but none worked for me.. TitleFromHTML = ie.document.all TitleFromHTML = ie.document.body TitleFromHTML = ie.document.getelementbyid(all) Please help. How to access entire HTML using Document Object Model (DOM)
This will return an array of all the tags in the body: var nBody = document.getElementsByTagName('body')[0] Code (markup): You can also use it, say, to return an array of all the h1 tags: var nH1 = document.getElementsByTagName('h1'); alert(nH1.length); Code (markup): This will return the HTML in between the body tags: var nHTML = document.getElementsByTagName('body')[0].innerHTML; Code (markup): If for some reason you need the body tag, too, then use: var nDoc = document.getElementsByTagName('*'); Code (markup): That array will include the head tags, the script tags, the style tags, meta tags, etc.
Thank you both a million. All the above worked fine in javascript, but the one from krakjoe also worked with vbs and that was great..
The above worked great in javascript or VBS visual basic script and all the other commands above worked in javascript. Is there anyway to get the other commands to work in Vbs? or wsh? I need to navigate to a page and grab the html source from the browser view, without haveing to do all the view source and file and save. I made the whs script to create Ie then navigage to a page and grab the html with the document.body.innerHTML but that requries me to grab all the html. If some of the other commands that work well in javascript would also work in vbs or wsh then I could just grab the specific section of html and not all of it.. I could not get any javascript command above to work with vbs with exceptions of the document.body.innerHTML and it works great. Thanks again.