How to Turn <This Bookmarklet> into a Form?

Discussion in 'JavaScript' started by Hyllier, Jan 24, 2011.

  1. #1
    Can anyone help me doing this? I want to turn this bookmarklet:

    javascript:try{s1=document.getElementsByTagName('body')[0].innerHTML.toString();s2=escape(s1.substr(s1.indexOf('flashvars.un'),128)+s1.substr(s1.indexOf('flashvars.title'), 128));location.href='http://somesite.something.com/index.html?input='+s2;}catch(err){location.href='http://somesite.something.com/index.html';}
    Code (markup):
    into a form, in a way that, the user inputs an URL and then click submit to "activate" bookmarklet's function in the same webpage the form is placed. I asked to a few people, but all they say is that "it is tricky" to do... Can anyone do it? I need this to be done and I'm kinda lost here,

    Thank you guys ;)

    P.S. Any kind of advice or HowTo will be useful.
     
    Hyllier, Jan 24, 2011 IP
  2. prasanthmj

    prasanthmj Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #2
    May be this?
    
    <form id='theform' >
    URL<br/>
    <input name='url' type='text'/>
    <br/><br/>
    <input name='submit' value='Submit' type='submit'/>
    </form>
    <script type='text/javascript'>
    function mysubmitform()
    {
        try
        {
        s1=document.getElementsByTagName('body')[0].innerHTML.toString();
        s2=escape(s1.substr(s1.indexOf('flash'+'vars.un'),128)+s1.substr(s1.indexOf('flash'+'vars.title'), 128));
        location.href=document.forms['theform'].url.value+'?input='+s2;
        }
        catch(err)
        {
        location.href=document.forms['theform'].url.value;
        }
    return false;
    }
    document.forms['theform'].onsubmit=mysubmitform;
    
    </script>
    
    HTML:
     
    prasanthmj, Jan 24, 2011 IP
  3. Hyllier

    Hyllier Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    @parsanthmj: Didn't work... Another way to do it?
     
    Hyllier, Jan 24, 2011 IP