Thursday, July 31, 2008

How to get the URL of the web page from a javascript?

var protocol = document.URL.split("//");
var urlParts = protocol[1].split("/");
var url = protocol[0]+"//"+urlParts[0]+"/"+urlParts[1]+"/app/RefreshServlet";
Protocol: http:, localhost:7001/GTEMWeb/app/searchRequest.do?
urlParts: localhost:7001, GTEMWeb, app, searchRequest.do?
protocol[0]: http:
urlParts[0]: localhost:7001
urlParts[1]: GTEMWeb
urlParts[2]: app

Tuesday, July 29, 2008

innerText, innerHTML, outerHTML

The below links help us understand better on how to access data using Javascript.

Link-I

Link-II

Link-III

How to get the html source of a jsp page and set it to a property of a form?

var htmlSource = document.getElementById("htmlSource");
htmlSource.value = document.documentElement.outerHTML;