Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Auto Submitting form Bookmarklet

    I have read a few forums on this but can't seem to get my bookmarklet to do what I want. I want it to act as a bookmark, bringing me to a page. (in my case myspace) then to fill in the fields. (IE - email, password) and lastly, submit it. That way I can just click the link once, and I'm logged in. I have a half working bookmarklet here:

    javascript:location.href='http://www.myspace.com';(function(){ var error = 0; var keepError = 'I tried my best, but I was unable to fill in your form perfectly.<br><br>'; var formsArray = content.document.getElementsByTagName('form');try{ formsArray[1]['email'].value='EMAIL@EXAMPLE.COM'; } catch(e){ error = 1; keepError = keepError + '- Form field email could not be found.<br>'; } try { formsArray[1].password.value='PASSWORD'; } catch(e){ error = 1; keepError = keepError + '- I can\'t set focus on the password field password.<br>'; } if(error == 1){ var newwin = window.open('', 'formsaver', 'HEIGHT=250,WIDTH=600,resizable=1,scrollbars=1'); newwin.document.writeln(keepError); newwin.document.close(); newwin.focus(); } })()

    (there is also an error checker in there which is not needed, nor part of the problem.)

    The problem with this is it will bring me to the page, but won't fill in the form. If I remove "location.href='http://www.myspace.com';", and use the bookmarklet whilst in the page, it will fill in the forms no problem. And from there, I have no idea how to auto submit it. I have been reading up on javascript only for the past 24 hours... so I am new to this. However, I have dabbled more so in programming and html. So I understand what's going on for the most part. Any help with this would be great!!!

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    There will be a timing problem. The bookmarklet should wait for the form to be fully loaded before submitting it. But the bookmarklet can't use window.onload while using location.href. So you can't have a script that will always work as intended. The alternative solution is to use GreaseMonkey scripts for Firefox or IE.

  • #3
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there a way I could Jimmy it to use perhaps a timeout function? And I'm running Firefox, and I've heard a lot about Greasemonkey, so I'll read up on that too. Thanks for the help.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    You could use a timeout function but it will not work all the time as pages don't load with constant time. The page might load fast and your script will still wait till the timeout expires before it does something in the form. Or the page might load very slow and the script timeout already expires before the page has completely loaded. So just use Greasemonkey scripts, it has more control of the page than using bookmarklet. It's as if the user script is really included in the page so you can virtually do anything in it as normal scripts do.

  • #5
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, got it installed. Seems like a pretty neat program. Thanks for the tip. Now I just need to fiddle with it a bit to get the hang of things. And oh yeah, learn javascript. :-P Filling a form shouldn't be too hard. I don't think... ??? lol. thanks again


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •