[英]Submit button with enter an url
我正在尝试创建一个书签,该书签将捕获当前页面的URL,即用户所在的位置,将该URL放入页面上表单的文本字段中,然后通过虚拟按下Submit按钮来提交表单。
使用以下代码,我获取当前页面的网址,使用url http://example.com/?url=http://www.url-of-the-current-page
进入站点,填写url http://www.url-of-the-current-page
进入表单的文本字段,但表单本身仍未提交:
javascript:(function(){ window.open('http://example.com/?url='+encodeURIComponent(location.href))})();
但是如何提交表单按钮? 整个表格如下所示:
<form ng-submit="launchTest()" class="ng-pristine ng-valid">
<input type="text" name="url" ng-model="url">
<input type="submit" value="Launch test" class="launchBtn" ng-class="{disabled: !url}">
</form>
我尝试了两种变体-并失败了:在两种变体中,我都停留在http://example.com?url=http://www.url-of-the-current-page
:
javascript:(function(){ window.open('http://example.com/?url='+encodeURIComponent(location.href));document.forms[0].submit()})();
javascript:(function(){ window.open('http://example.com/?url='+encodeURIComponent(location.href));document.forms[this.form.id].submit()})();
(代表OP张贴) 。
我已经联系了网站所有者,我想在其中运行我的小书签-他说,我的小书签是正确的,但是对于提交表单,URL应该包含一个特殊参数,例如&run=1
。 使用此参数,该线程中提到的每个小书签都可以工作(工作意味着不仅打开新标签并输入url,而且还提交表单)。 我将使用的工作书签是:
javascript:(function(){var win=window.open('http://example.com?url='+encodeURIComponent(window.location.href )+'&run=1','_blank');win.focus();})()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.