本文目錄一覽:
- 1、js複製文本框內容到剪切板實現換行
- 2、js如何通過表單文本框的設置來改變圖片上的內容
- 3、js如何還原文本框內容
- 4、在html靜態頁面中,如何使用js把頁面中的文本框的內容寫入到另外一個html文件中,或是寫入到txt文檔中?
- 5、js獲得一個文本框中的值複製到另一個中應如何改
- 6、js 表單切換
js複製文本框內容到剪切板實現換行
script type=”text/javascript”
function copyUrl2()
{
var Url2=document.getElementById(“biao1”).innerText;
var oInput = document.createElement(‘input’);
oInput.value = Url2;
document.body.appendChild(oInput);
oInput.select(); // 選擇對象
document.execCommand(“Copy”); // 執行瀏覽器複製命令
oInput.className = ‘oInput’;
oInput.style.display=’none’;
alert(‘複製成功’);
}
/script
div cols=”20″ id=”biao1″12345678/div
input type=”button” onClick=”copyUrl2()” value=”點擊複製代碼” /
js如何通過表單文本框的設置來改變圖片上的內容
!DOCTYPE html
html lang=”en”
head
meta charset=”UTF-8″
/head
body
請選擇圖片:input type=”file” id=”file” accept=”image/*”/
請輸入水印文字:input type=”text” id=”text”/
button type=”button” id=”ok”確定/button
canvas id=”stage”
瀏覽器版本太低,請更新瀏覽器以便支持canvas
/canvas
script type=”text/javascript”
var $ = document.querySelector.bind(document);
var file = $(‘#file’),
text = $(‘#text’),
button = $(‘#ok’),
stage = $(‘#stage’),
ctx = stage.getContext(‘2d’);
file.onchange = function (e) {
var file = e.target.files[0];
var image = new Image();
var reader = new FileReader();
reader.onload =function(){
image.src = reader.result
};
reader.readAsDataURL(file);
image.onload = function () {
stage.width = this.width;
stage.height = this.height;
ctx.drawImage(this, 0, 0,this.width,this.height);
};
};
button.onclick = function () {
var textValue = text.value;
if(!textValue) alert(‘請輸入水印文字’);
ctx.fillStyle=’red’;
ctx.font = ‘150px Arial’;
ctx.fillText(textValue,20,stage.height – 40);
}
/script
/body
/html
js如何還原文本框內容
這個代碼 無法實現
IE是本身保存了你的數據 並不是 你的load_CurrentText() 工作了
解決方法 是用js本地重寫頁面內容 避免出現頁面跳轉
在html靜態頁面中,如何使用js把頁面中的文本框的內容寫入到另外一個html文件中,或是寫入到txt文檔中?
問問你,你是想把提交的姓名手機等信息放到文件里存起來,還是只是想在頁面上顯示下,下次就不用了?如果是後者,js就搞定了,如果是前者,就麻煩了,需要在後台實現,因為js不能操作文件
js獲得一個文本框中的值複製到另一個中應如何改
script
function cal(){
var rem = document.getElementById(‘txt1’).value;
document.getElementById(‘txt2’).value = rem;
}
/script
/head
body
form action=”” method=”get” name=”myform”
input id=”txt1″ type=”text”
input id=”txt2″ type=”text”
input name=”” onClick=”cal();” type=”button” value=”確定”
/form
/body
js 表單切換
假設你的郵件發送對應的action是SendMail.asp,
把你的submit按鈕改成type=”button”,加一個onclick函數
先判斷哪個radio被選中(具體寫發百度一下吧)
如果是「普通」,則用document.form1.action=”SendMessage.asp”
如果是「重要」,則document.form1.action=’SendMail.asp’
最後document.form1.submit()
PS.name=form1 , action=SendMessage.asp ,method=post這些,後面那個最好還是用個引號括起來吧。。。
再PS.沒人覺得你是要用outlook…..可能是你沒明白我和樓上的意思
原創文章,作者:Y744J,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/128896.html