Enter an URL and click the submission button

I'm currently working on a bookmarklet that can grab the URL of the page the user is on, insert that URL into a text field on a specific form, and then automatically submit the form.

Here is the code I have so far. It successfully captures the current page's URL, redirects to a specific site with the URL parameter included, and fills the form's text field with the URL. However, the form itself does not automatically submit:

javascript:(function(){ window.open('http://example.com/?url='+encodeURIComponent(location.href))})();

My question is: How can I make the form submit automatically? The HTML code for the form is as follows:

<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> 

I have tried two different approaches, but unfortunately, I have been unsuccessful. In both cases, I remain on the same page

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()})();

Answer №1

(As shared by the OP).

After reaching out to the website owner to inquire about running my bookmarklet, I received confirmation that my bookmarklet was indeed correct. However, in order for the form submission to work properly, a special parameter needed to be included in the URL, such as &run=1. This adjustment allowed all bookmarklets mentioned in the discussion to function as intended (meaning they not only opened a new tab and inputted the URL, but also submitted the form). The updated, working bookmarklet that I will be using is:

javascript:(function(){var win=window.open('http://example.com?url='+encodeURIComponent(window.location.href )+'&run=1','_blank');win.focus();})()

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Connecting the value of one input to influence another input

There are two input boxes provided - one for current address and another for permanent address. When the checkbox is clicked, the value of the current address should be displayed in the permanent address box. However, I am facing an issue where when I unc ...

Searching for Bluetooth devices using React Native

In my project, I am working on scanning HM-10 BLE with a react-native app. To achieve this, I referred to the example provided in Scanning for Bluetooth devices with React Native. So far, the library seems to be successfully installed without any errors du ...

Determine the total value derived from adding two option values together

I am attempting to calculate the sum of two select options and display the result. So far, my attempts have only resulted in returning the value 1. What I am aiming for is to add the values from n_adult and n_children, and then show the total under Numbe ...

What steps can be taken to send the user to the login page after their session token has expired

Currently, I am using a Marionette + Node application. I have noticed that when the token expires, the application does not respond and the user is not redirected to the LogIn page. My question is, how can I set up a listener to check the session token s ...

Prevent a dynamically generated text input from being used if it exceeds a specific character limit in VUE.JS

I am currently working on a Vue template that dynamically creates Bootstrap text inputs. The goal is to allow the user to retrieve the values onSubmit from these inputs. One requirement I have is to disable an input if the length of the text exceeds 10 ch ...

Safari's Web Audio API suffering from subpar performance and various shortcomings

For my University project, I am developing an HTML and JavaScript-based mp3 player using the Web Audio API. You can check out the progress of this project by visiting this link: While everything is running smoothly on Firefox and Chrome, Safari is posing ...

Adding numbers to a textbox using a JavaScript algorithm

There are two textboxes in this scenario. The first box should always contain 4 digits when you leave it, while the second box should always contain 10 digits. A javascript function needs to be implemented so that when a user leaves one of the textboxes, ...

Guide on effectively sending a secondary parameter in an ajax request

Struggling to implement a year/make/model multi-select feature, I have managed to get the scripts working. However, what appears to be missing is the ability to pass both a year and make variable together in order to fetch the final model results. Below a ...

Create seamless communication between Angular application and React build

I am currently engaged in a project that involves integrating a React widget into an Angular application. The component I'm working on functions as a chatbot. Here is the App.tsx file (written in TypeScript) which serves as the entry point for the Rea ...

Execute index.js code from index.html using NodeJS and Express

Currently, I am diving into the world of NodeJS and Express using Replit.com for a small project. The main objective is to develop a basic input field that, upon submission, will post to different channels such as Discord and Twitter. The piece of code be ...

Displaying the identical date on two separate Ajax Calendar Extender controls in Asp.net

I am facing an issue with some ajax calendar extenders. I have two similar calendars and two textboxes, each linked to one calendar. <asp:TextBox ID="txt1" runat="server"</asp:TextBox> <cc1:CalendarE ...

Infinite loop occurring when setting state to child component in React

On a page featuring dropdown menus for content searching, the dropdown is non-functional but provides context. This page serves as a listing page. After performing calculations on the listing page and updating the state, I encounter an infinite loop when ...

My regular simple form is experiencing issues with AngularJS and jQuery functionality

I am currently expanding my knowledge in AngularJS and have created a simple form. However, as a PHP developer, I decided to utilize PHP as the server-side scripting language. I am encountering difficulties in submitting the data to the server, despite try ...

Metronome in TypeScript

I am currently working on developing a metronome using Typescript within the Angular 2 framework. Many thanks to @Nitzan-Tomer for assisting me with the foundational concepts, as discussed in this Stack Overflow post: Typescript Loop with Delay. My curren ...

How can you automatically show the current time upon entering a page using React Native?

Is there a way to automatically display the current time when a user enters the page? I currently have code that only shows the current time when the TouchableOpacity is pressed, but I want it to update automatically as soon as the user arrives on the Ne ...

How can I prevent v-model from filling multiple fields?

Having just started with Vue.js, I've managed to solve most of the issues I've encountered so far, but there's one that's stumping me. I'm working on displaying a list of posts fetched from an API and I want to include a comments ...

JavaScript - Functions in objects losing reference to previously created object properties

Having trouble with my Candy function. When I create an object of the Candy function, all attributes are created correctly. However, when I try to run the draw function, it always uses the properties of the second object created instead of the one I want. ...

Problems with radio button serialization in jQuery form plugin

I've created a basic form: <form class="dataform" method="post" id="settings" action="/"> <input type="radio" name="shareSetting" value="n"/> <input type="radio" name="shareSetting" value="y"/> <input type="button" na ...

Seeking help with executing JQuery Ajax functions within a foreach loop

Currently, I am engrossed in the study of programming and endeavoring to construct a website utilizing .Net Core. The predicament at hand pertains to my limited acquaintance with JavaScript while incorporating two JQuery/AJAX functions on my Index page - o ...

Refresh the Document Object Model (DOM) and transmit the present time

I am having an issue with sending the actual current time when a button is clicked. Instead of getting the current time, I am receiving the time when the page initially loaded. This button is used to submit a form on Google Sheets using an API. This is th ...