Friday, February 22, 2008

iframes and history

Iframes implements history on their own. They are not necessarily realted to the window history. Accessing that history creates a problem when the window and frames belong to different domains. The familiar "Access denied" or "permission denied" pops up on the IE. IE also doesn't allow access to the properties of location object. So parent frame is not allowed to know the location details of the child frame. Now if the parent doesn't know the location details of the child, how can it reload the child frame. Now reloading a child frame by parent frame is no security violation and is allowed in case of Mozilla. I wouldn't let IE take credit for more security because it is plain baseless. When a page is allowed to open a page in its iframe, why isn't it allowed to reload it or make it move back or forward!
Problem: Open a page in iframe, navigate through its links, reload the last page that was visible Possible approaches: in iframe.window.reload causes the whole page to reload, window.history.go(0) too does that. iframe.src="dummy page" --> window.history.go(-1); loads the page from the cache and not the server. iframe.src="javascript" - doesn't work for cross domain pages.
To bypass this problem, I created 3 tier structure: window --> frame1 --> frame 2
frame 1 is local to window and frame 2 loads a different domain. Now the user navigates in the frame 2 using its links, and reaches a page he wants to be reloaded again. Now if there is a button on the window which refreshes the frame 1 (possible since its local to window), the frame 2 refreshes to the last page in it and not the one defined in the src attribute off rame 2.
Quite a feat for me as i could not find this approach even on extensive searching on net.

Monday, February 4, 2008

web dekstop

1. Javascript - frames and pop up windows
  • Javascript doesn't let the two frames communicate when both of them are from different domains
  • The above also applies when pop up windows are opened
  • Javascript lets location.href property of a frame(child/parent) or window (child/parent) to be set but not read if both are from different domains.
2. Javascript has onbeforeunload which can stop reloading of a page with a confirm box. It also lets you add some text to it

3. Javascript provides no way to stop the page from loading at onunload stage
4. target properties can alter the way windows and frames react with their parents. _top, _self,_parent etc.
5. providing the names of the frames enable to be found when accessed by document.frames[0] without which it will fail. -- not tried though, i guess i just read it.
6. divs can be made resizable but not editable by providing disabled preoperty with contentEditable property
7. onresize method is useless!!
8. javascript can be run in the address bar and huge things can be accomplished by it, including the way things look on a static page! try web preview.
9. there is a security property in a frame, when specified all the hrefs and form submits will opena new page.
10. implemented drag and drop for the first time - was an awesome feeling!
Java
1. URL connection is wrapped by HttpURL connection a much richer class.
2. when the page redirects from a url to another, the another url is also available once the connection has been set. This url also has the path relative to the url used to hit the site.
3. Downloaded the html of a page using java... awesome!
4. System.setProperty("http.proxyHost", "10.100.0.8");
System.setProperty("http.proxyPort", "3129");
when trying to connect a server using URLconnection and trying it behind proxies.