日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > php >内容正文

php

php对话框制作,js制作一个简单的对话框教程

發(fā)布時(shí)間:2024/10/14 php 112 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php对话框制作,js制作一个简单的对话框教程 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)簡(jiǎn)易聊天對(duì)話框,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了js實(shí)現(xiàn)簡(jiǎn)易聊天對(duì)話框的具體代碼,供大家參考,具體內(nèi)容如下

聊天對(duì)話框

*{font-size: 14px; padding:0; margin:0;}

.main{

position: relative;

margin: 20px auto;

border: 1px solid steelblue;

width: 430px;

height: 400px;

}

.msgInput{

display: block;

width: 406px;

height: 60px;

margin: 10px auto;

}

.sendbtn{

position: absolute;

width: 100px;

height: 29px;

bottom: 5px;

right: 10px;

}

.content{

list-style: none;

width: 410px;

height: 280px;

margin: 5px auto;

border: 1px dotted #D1D3D6;

overflow-y: scroll;

}

.msgContent{

width:auto;

max-width: 250px;

height: auto;

word-break: break-all;

margin: 5px;

padding: 3px;

border-radius: 5px;

}

.content .left{

float: left;

text-align: left;

background-color: lightgrey;

}

.content .right{

float: right;

text-align: right;

background-color: yellowgreen;

}

window.οnlοad=function(){

var input = document.getElementById('msg_input');//查找緩存

document.getElementById('sendbtn').οnclick=function () {

//var input1 = document.getElementById('msg_input');//

//input0

sendMsg();

}

//快捷鍵 發(fā)送

document.onkeypress = function (event) {

var e = event || window.event;

var keycode = e.keyCode || e.which;

console.log(e)

if( keycode==10){//判斷同時(shí)按下ctrl 和enter

sendMsg()

}

}

function sendMsg() {

var input = document.getElementById('msg_input');//查找緩存

var ul = document.getElementById('content');

var newLi = document.createElement('li');

newLi.innerHTML = input.value;

newLi.className = 'msgContent right';

ul.appendChild(newLi);

var p = document.createElement('p');

p.style = 'clear:both';

ul.appendChild(p);

ajax({

url:'http://jisuznwd.market.alicloudapi.com/iqa/query?question='+input.value,

success:function (res) {

// console.log(res)

var obj = JSON.parse(res);

console.log(obj)

var array = obj.result.content;

// var zhengzhou = array[0];

var tmp = array;

// var tmp = '溫度:'+zhengzhou.day_air_temperature+','+zhengzhou.day_weather;

console.log(tmp)

var newLi = document.createElement('li');

newLi.innerHTML = tmp;

newLi.className = 'msgContent left';

ul.appendChild(newLi);

var p = document.createElement('p');

p.style = 'clear:both';

ul.appendChild(p);

input.value = '';

newLi.scrollIntoView();//將元素滾動(dòng)到可見位置

}

})

input.value = '';

newLi.scrollIntoView();//將元素滾動(dòng)到可見位置

}

}

function ajax(obj) {

//?lastCursor=6610&pageSize=10

// var url = 'reg.php';

var xhr = null;

if(window.ActiveXObject){

xhr = new ActiveXObject('Microsoft.XMLHTTP')

}else{

xhr = new XMLHttpRequest();

}

// $username = $_REQUEST['username'];

// $password = $_REQUEST['password'];

//打開與服務(wù)器的連接

if(obj.method){

xhr.open(obj.method,obj.url,true);

}else{

xhr.open('get',obj.url,true);

}

xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

xhr.setRequestHeader("Authorization","APPCODE 3e9dfb924f464e9593a95f9d2bbf4348")

// {username:'zhangsa',password:123123}

// sendData = encodeURIComponent(sendData);

// 發(fā)送請(qǐng)求

//console.log(res);

//回調(diào)函數(shù)

xhr.onreadystatechange = function () {

// console.log(xhr.readyState)

if(xhr.readyState == 4){

//數(shù)據(jù)接收完畢

if(xhr.status == 200){

// console.log('請(qǐng)求成功',xhr.responseText)

if(obj.success){

obj.success(xhr.responseText)

}

}else{

// console.log(xhr.status,'請(qǐng)求出錯(cuò)')

if(obj.failure){

obj.failure('請(qǐng)求失敗')

}

}

}

}

// var sendData = 'username=zhangsan&password=123456';

if( obj.method == undefined ||obj.method.toLowerCase() =='get'){

xhr.send(null);//

}else{

xhr.send(obj.params);//

}

}

  • hello?
  • hello
  • hi
  • hehe
  • goodbye
  • 。。。。
  • sdfasdsadfd fasd fasd fasdfasdfasdf
  • 哈哈

發(fā)送

總結(jié)

以上是生活随笔為你收集整理的php对话框制作,js制作一个简单的对话框教程的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。