我試圖從我的JavaScript函式中打開一個網頁:
function fillText() {
window.open("https://Somerandonwebsite.com/task") 。
網頁:"https://Somerandonwebsite.com/task "有一個文本框,標簽如下:
< input type="text" id="titleBox" autocomplete="off" aria-label="Title Field" title=" placeholder="Enter Title" aria-invalid="true">
我想在id為titleBox
我怎樣才能在函式中實作這一點?我也很困惑,是先添加字串并打開網頁,還是先打開網頁并訪問文本框來填充我的字串
。我怎樣才能在打開網頁時訪問文本框,將這個字串填入文本框中呢?
uj5u.com熱心網友回復:
正如@Carsten L?vbo Andersen的評論所說,如果你擁有兩個網站,你可以直接從你的函式中傳遞一些查詢字串到你的網站。例如:
function fillText(){
window.open("https://Somerandonwebsite.com/task?string=yourString") 。
然后,在你的Somerandonwebsite.com,簡單地創建一個腳本:
var input = document. getElementById("titleBox"/span>)。
const params = new URLSearchParams(window. location.search)
input.value = params.get("string"/span>)
這將使你的文本框顯示你的查詢字串,名為string
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/306723.html
標籤:
上一篇:使用JQuery改變CSS(影片
