我一直在使用bookmarklet并制作了一个在iframe
中包装页面然后放置一个表单以便我可以将数据提交到我的服务器但是我无法从页面获取PHP变量。
示例代码(已编译为:http://moxleystratton.com/javascript/bookmarklet-compiler上的bookmarklet):
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>')})());
答案 0 :(得分:2)
首先修复你的JS:
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>')})());