0

I have been playing with bookmarklets and made one that wraps a page in an iframe then puts a form so I can submit data to my server but I can't get PHP variables from the page.

sample code (have been compiling to bookmarklet at: http://moxleystratton.com/javascript/bookmarklet-compiler):

javascript:void((function(){
var a=document;
a.write(
      '<!DOCTYPE html>
      <html>
          <head>
          <meta charset="UTF-8">
          <title>'+a.title+' - Edit Mode </title>
      </head>
      <body>
      <section>
      <div id="wrapper">
      <iframe src="'+a.URL+'" >
      </iframe>
      </div>
      </section>
      <footer>
            <form action="/sys/manage/seo.php" method="post">
    <input type="hidden" value=rawData >
    <label for="title">Title</label>
    <input type="text" name="title" value="<?= $title;?>">
    <label for="title">Meta-Description</label>     
    <input type="text" name="meta-desc" value="<?= $data->meta-desc;?>">
    <label for="title">Meta-Keywords</label>        
    <input type="text" name="meta-key" value="<?= $data->meta-key;?>">
</form>
      </footer>
      </body>
      </html>')})());
Mitchell Bray
  • 558
  • 2
  • 14
  • 29

1 Answers1

2

First fix your JS like this:

void((function(){
var a=document;
a.write(
      '<!DOCTYPE html>\
      <html>\
    <head>\
          <meta charset="UTF-8\
          <title>'+a.title+' - Edit Mode </title>\
      </head>\
      <body>\
      <section>\
      <div id="wrapper">\
      <iframe src="'+a.URL+'" >\
      </iframe>\
      </div>\
      </section>\
      <footer>\
            <form action="/sys/manage/seo.php" method="post">\
    <input type="hidden" value=rawData >\
    <label for="title">Title</label>\
    <input type="text" name="title" value="<?= $title;?>">\
    <label for="title">Meta-Description</label>     \
    <input type="text" name="meta-desc" value="<?= $data->meta-desc;?>">\
    <label for="title">Meta-Keywords</label>        \
    <input type="text" name="meta-key" value="<?= $data->meta-key;?>">\
</form>\
      </footer>\
      </body>\
      </html>')})());

Demo here : http://jsfiddle.net/shahverdy/Z5EBk/

Mostafa Shahverdy
  • 2,687
  • 2
  • 30
  • 51