0

I am trying to open a webpage from my JavaScript function:

function fillText() {   
      window.open("https://Somerandonwebsite.com/task");      
  }

The webpage : "https://Somerandonwebsite.com/task" has a text box with the following tag:

<input type="text" id="titleBox" autocomplete="off" aria-label="Title Field" title="" placeholder="Enter Title" aria-invalid="true">

I want to add string "Title created" to the text box with the id titleBox

How can I achieve this in the function? I am also confused whether to add the string first and open webpage or open webpage and access text box to fill my string

How can I access text box to fill this string into the text box on opening web page?

3
  • I don't believe you can, since when you leave your website you also leave your code. Commented Sep 15, 2021 at 5:57
  • Any way so that i can open the webpage with the textbox field filled with my string? @CarstenLøvboAndersen Commented Sep 15, 2021 at 5:58
  • Not unless you own both sites, then you can make it happen with some query strings and other code Commented Sep 15, 2021 at 5:59

1 Answer 1

1

As @Carsten Løvbo Andersen's comment said if you own both sites, you can just pass some query strings from your function to your site. E.G.

function fillText() {   
  window.open("https://Somerandonwebsite.com/task?string=yourString");
}      

Then, at your Somerandonwebsite.com, simply create a script:

var input = document.getElementById("titleBox");
const params = new URLSearchParams(window.location.search)
input.value = params.get("string")

This will make your text box display your query string named string

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.