Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I access the html code of a window with javascript

Status
Not open for further replies.

jllinko

MIS
Mar 7, 2001
5
US
Is it possible to access the html source code of a window via javascript. For example

alert(window.xxxx) where the alert box show the same data as right clicking on the window and viewing the source.
 
this works in IE 5+

alert(document.documentElement.outerHTML); luciddream@subdimension.com
 
Thnaks for the speedy reply, but unfortunatly, our company uses NS4.x only. Anyone have a NS soultion?

Link
 
this should work in IE5:

document.getElementsByTagName("HTML")[0].outerHTML;

and something like the following should work in NS6(except you'll be missing the HTML tags):

docoment.documentElement.innerHTML jaredn@eae.net -
 
wow, that is bad... you should try to convince them to atleast upgrade...

if you were using NS6 you could use:

alert(document.documentElement.innerHTML) and it would give you everything except the <html> tags.

luciddream@subdimension.com
 
oh, didn't see your post, and no, you won't be able to get the source w/o storing it in a variable yourself. jaredn@eae.net -
 
Man... Thanks for all the replies. First time on this board, I'm impressed.

Link
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top