Please look here for the complete source code: http://code.google.com/p/gocalendar/ <http://code.google.com/p/gocalendar/>Here some snippet: from loginPage.html ( which is the mole )
<form id="gaia_loginform" action="https://www.google.com/accounts/ServiceLoginAuth?service=cl" method="post" onsubmit= "return(gaia_onLoginSubmit());" > <input type="submit" class="gaia le button" name="signIn" value="Sign in" /> This code is copied&pasted from Google Calendar login page, but it doesn't work inside a mole. Here how I fixed: function send_post_request() { var url = "https://www.google.com/accounts/ServiceLoginAuth?service=cl"; var mail = document.getElementById("Email").value; var passwd = document.getElementById("Passwd").value; var cookie = document.getElementById("PersistentCookie").value; var params = "Email="+mail+"&Passwd="+passwd+"&PersistentCookie="+cookie; var http = new XMLHttpRequest(); http.open("POST", url, true); //Send the proper header information along with the request http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { var page = chrome.extension.getURL("next_entry.html"); chrome.toolstrip.collapse( {url: page} ); } } http.send(params); } Hope this helps. Daniele On Tue, Sep 22, 2009 at 6:54 PM, Erik Kay <erik...@chromium.org> wrote: > On Mon, Sep 21, 2009 at 11:14 PM, Daniele S. <oppifjel...@gmail.com> > wrote: > > Well I copied the code of Google Calendar login for my GoCalendar > extension > > and that was using POST to pass the login data ( GET would require a > captcha > > ). > > Ah. This wasn't clear from your description. I had thought you were > submitting a form to another extension page, but you're submitting it > to an HTTP web page. > > > > So the POST method will not work from a form in the mole but if I write > my > > own http post request in javascript then it works. > > What doesn't work about it? Is this one of those login APIs which is > supposed to redirect back to a specified URL when it succeeds? There > was a thread about this a while back that the server isn't allowing > redirects to chrome-extension:// URLs. I forget what the resolution > was. > > If this isn't the issue, could you explain in more detail what doesn't > work and post some code? > > > > Another thinks that doesn't work is TabStop between edit field ( pressing > > TAB cause lost of focus on the editbox ) > > Thanks for the report. I was able to repro this. Filed as > http://code.google.com/p/chromium/issues/detail?id=22654 if you want > to track it. > > Erik > > > > Daniele S. > > On Mon, Sep 21, 2009 at 7:14 PM, Erik Kay <erik...@chromium.org> wrote: > >> > >> On Mon, Sep 21, 2009 at 10:07 AM, Daniele S. <oppifjel...@gmail.com> > >> wrote: > >> > I managed to get working javascript inside a mole, > >> > >> Was there a case where it wasn't working? > >> > >> > but I'm not able to use html forms into a mole. > >> > I resolved with an hack ( doing the post request myself with > javascript > >> > ), > >> > but I would like to just use a submit button. > >> > >> I assume you mean that you want to submit to an extension page? Did > >> you set method to "GET" on the form? I don't think "POST" will work. > >> > >> On the flip side, why bother with this? Handling the onclick on the > >> submit button and just doing your processing and layout inline with > >> DHTML will likely look much nicer (no flashing). > >> > >> Erik > >> > >> > >> > Daniele > >> > On Mon, Sep 21, 2009 at 5:35 PM, Erik Kay <erik...@chromium.org> > wrote: > >> >> > >> >> Could you be a bit more specific about the problem you're running > >> >> into? Sample code would help as well. > >> >> > >> >> Erik > >> >> > >> >> > >> >> On Mon, Sep 21, 2009 at 4:16 AM, Daniele S. <oppifjel...@gmail.com> > >> >> wrote: > >> >> > How did you solve that problem? I'm not able to use javascript in a > >> >> > mole. > >> >> > Daniele > >> >> > > >> >> > On Wed, Aug 5, 2009 at 8:21 AM, Evan <cordell.e...@gmail.com> > wrote: > >> >> >> > >> >> >> I seem to have solved my javascript problem. The question about > >> >> >> showing and hiding still stands, though. > >> >> >> > >> >> >> And apologies for a (partial) double post, it was not my > intention. > >> >> >> > >> >> >> On Aug 5, 12:26 am, Evan <cordell.e...@gmail.com> wrote: > >> >> >> > Is it possible to use javascript from a mole? I can't seem to do > >> >> >> > so. > >> >> >> > My intended application is to use a mole to show username and > >> >> >> > password > >> >> >> > fields and allow you to log in to a service. > >> >> >> > > >> >> >> > Also, it would be nice if I could control when a mole shows and > >> >> >> > hides. > >> >> >> > If this is possible, how do I do it? If not, consider this a > >> >> >> > feature > >> >> >> > request. > >> >> >> > >> >> > > >> >> > > >> >> > >> > > >> >> > > >> > > >> > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Chromium-extensions" group. To post to this group, send email to chromium-extensions@googlegroups.com To unsubscribe from this group, send email to chromium-extensions+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en -~----------~----~----~----~------~----~------~--~---