Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes Problem accessing the form object of a different frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Problem accessing the form object of a different frame" Watch "Problem accessing the form object of a different frame" New topic
Author

Problem accessing the form object of a different frame

T Zaman
Greenhorn

Joined: Oct 31, 2005
Posts: 18

Hi , I would like to submit the form of an external webpage using frame. I have two frame, top frame has the button . If I click that button I want to call the submit action on a form(the form is logging in the user ) which is calling different webpage. I am posting my code. Please let me know is this possible using java script or I should take different approach such as JSP or AJAX? If I take different approach like Jsp or Ajax, then how should I do that and if I can use java scipt then what is the problem here or what should I do here . Please Help





SCJP 5.0 SCWCD 5.0
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

I think you should use Window.parent instead of using parent directly. Also location.src is not a property I think (It is an attribute of frame tag). So you can either use the src property on the frame or href on the location of the frame. Also I think changing the location of a frame will be asynchronous. So in the code



The code after the href statements will be executed even if the page https://gx-support.sun2.lightsurf.net is not loaded completely. Lastly if that page seems to have just a simple form with handler (with the value adminLoginWithPassword), login and password fields. The form points to /authenticate so instead of doing all this mess, you can directly point your frame to https://gx-support.sun2.lightsurf.net/authenticate?handler=adminLoginWithPassword&login=xxx&password=yyy or you can make an ajax request, sending the parameters as request body. I hope I've not misinterpreted anything ...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
T Zaman
Greenhorn

Joined: Oct 31, 2005
Posts: 18
Thanks Ankit for the advise. I will sure try that. I dont want to point the frame directly like this "https://gx-support.sun2.lightsurf.net/authenticate?handler=adminLoginWithPassword&login=xxx&password=yyy" as I want to automate the login . I will try using Ajax.thanks a lot for the advise

Ankit Garg wrote:I think you should use Window.parent instead of using parent directly. Also location.src is not a property I think (It is an attribute of frame tag). So you can either use the src property on the frame or href on the location of the frame. Also I think changing the location of a frame will be asynchronous. So in the code



The code after the href statements will be executed even if the page https://gx-support.sun2.lightsurf.net is not loaded completely. Lastly if that page seems to have just a simple form with handler (with the value adminLoginWithPassword), login and password fields. The form points to /authenticate so instead of doing all this mess, you can directly point your frame to https://gx-support.sun2.lightsurf.net/authenticate?handler=adminLoginWithPassword&login=xxx&password=yyy or you can make an ajax request, sending the parameters as request body. I hope I've not misinterpreted anything ...
 
 
subject: Problem accessing the form object of a different frame