A script for dragging the table to exchange cell data ^

xiaoxiao2021-03-06  63

Drag and drop the table to exchange cells of cells, huh, copy, try it:)

Drag </ Title> <style> Td {width: 20%; Height: 20px; border-bottom: 1px solid black; border-right: 1px solid black; cursor: default;} div} TH {height: 20px; font-size: 12px; font-weight: Normal; border-bottom: 2px solid black; background-color: #cccccccc} table {border: 1px solid black; font-size: 13px;} </ Style> <script language = "javascript"> / ******************************************* DRAGEDTABLEDATA.JS ****************************** * ****************** **************************************************************** *** // * * create by lxcjie 2004.4.12 * You can implement internal drag of table content * Make sure the existence of the intermediate excess layer, ID is specified * / / * -------- global variable --- -------- * / var dragedTable_x0, dragedTable_y0, dragedTable_x1, dragedTable_y1; var dragedTable_movable = false; var dragedTable_preCell = null; var dragedTable_normalColor = null; // start color of the cell var dragedTable_preColor = "lavender"; / / Target cell color var DragedTable_endcolor = "#ffccff"; var DragedTable_Moveddiv = "DR AgedTable_Movedddiv "; var dragedtable_tableid =" "; / * ------------------- * /</p> <p>function DragedTable (tableId) {dragedTable_tableId = tableId; var oTempDiv = document.createElement ( "div"); oTempDiv.id = dragedTable_movedDiv; oTempDiv.onselectstart = function () {return false}; oTempDiv.style.cursor = "hand"; oTempDiv.style.position = "absolute"; oTempDiv.style.border = "1px solid black"; oTempDiv.style.backgroundColor = dragedTable_endColor; oTempDiv.style.display = "none"; document.body.appendChild (oTempDiv); document .all (TableID) .onMousedown = showdiv;} // Get the absolute position of the control function getpos (cell) {var pos = new array (); var t = cell.offsettop; var l = cell.offsetleft; while (Cell = Cell.offSetParent) {t = cell.offSettop; L = Cell.offsetleft;} POS [0] = T; POS [1] = L; Return Pos;</p> <p>// Display layer function showdiv () {var obj = event.srcelement; var pos = new array (); // Get excess layer var = document.all (DrageDTable_Movedddiv); if (obj.tagname.tolowercase () == "TD") {Obj.style.cursor = "hand"; POS = getpos (obj); // calculate the intermediate overlay position, assign the value odiv.style.Width = Obj.OffsetWidth; ODIV.Style.Height = Obj .offsetheight; odiv.style.top = POS [0]; odiv.style.left = POS [1]; odiv.innerhtml = obj.innerhtml; odiv.style.display = "; DrageDTable_x0 = POS [1]; DragedTable_y0 = pos [0]; dragedTable_x1 = event.clientX; dragedTable_y1 = event.clientY; // remember the original td dragedTable_normalColor = obj.style.backgroundColor; obj.style.backgroundColor = dragedTable_preColor; dragedTable_preCell = obj; dragedTable_movable = true;}} Function Dragdiv () {if (DragedTable_Movable) {var = document.all (DrageDTable_Moveddiv); VAR POS = New Array (); oDiv.style.top = event.clientY - dragedTable_y1 dragedTable_y0; oDiv.style.left = event.clientX - dragedTable_x1 dragedTable_x0; var oTable = document.all (dragedTable_tableId); for (var i = 0; i <oTable.cells .length; i ) {if (otable.cells [i] .tagname.tolowercase () == "TD") {POS = getpos (otable.cells [i]); if (Event.x> POS [1] && Event .x <pos [1] otable.cells [i] .offsetwidth && event.y> pOS [0] && event.y <pOS [0] </p> <p>oTable.cells [i] .offsetHeight) {! if (oTable.cells [i] = dragedTable_preCell) oTable.cells [i] .style.backgroundColor = dragedTable_endColor;}! else {if (oTable.cells [i] = dragedTable_preCell) Otable.cells [i] .style.backroundcolor = DragedTable_NORMALCOLOR;}}}}}</p> <p>function hideDiv () {if (dragedTable_movable) {var oTable = document.all (dragedTable_tableId); var pos = new Array (); if (dragedTable_preCell = null!) {for (var i = 0; i <oTable.cells.length ; i ) {POS = getPOS (Otable.cells [i]); / / calculate the mouse position, whether it is within a certain cell range if (Event.x> POS [1] && event.x <POS [1] Otable.cells [i] .offsetwidth && event.y> POS [0] && event.y <pOS [0] otable.cells [i] .offsetHeight) {if (otable.cells [i] .tagname.tolowercase () == "TD") {// Exchange text DrapeTable_precell.innerhtml = otable.cells [i] .innerhtml; otable.cells [i] .innerhtml = document.all (DrageDTable_Moveddiv) .innerhtml; // Clear the original cell And target single style DrapeTable_precell.style.backgroundcolor = DragedTable_NORMALCOLOR; Otable.cells [i] .sty le.backgroundColor = dragedTable_normalColor; oTable.cells [i] .style.cursor = ""; dragedTable_preCell.style.cursor = ""; dragedTable_preCell.style.backgroundColor = dragedTable_normalColor;}}}} dragedTable_movable = false; // Clear FIG tips Layer Document.all (DrageDtable_Moveddiv) .style.display = "none";}}</p> <p>Document.onmouseUp = function () {hidediv (); var ot = document.all (DrageDTable_TableID); for (var i = 0; i <otable.gength; i ) otable.cells [i] .style.backgroundColor = DragedTable_normalcolor; Document.onmouseMove = function () {Dragdiv ();</p> <p>/ ********************************* DRAGEDTABLEDATA.JS end ********* *********************************************************** ********** DRAGEDTABLEDATA.JS ends **************************************** / </ script> <script language = "javaScript"> Function init () {// Register the dragable table New DragedTable ("TableID");} </ script> </ head> <body οncοntextmenu = "Return False;" οnlοad = "init ()> <Table ID = "TableID" width = "70%" align = "center" cellpadding = "0" cellspacing = "0"> <tr> <tr> "> Drag Exchange cell content </ th> </ tr> <tr> <td> java </ td> <td> java one </ td> <td> jbuilder </ td> <td> stuts </ td> </ Tr> <tr> <TD> C </ TD> <TD> Visual Studio </ TD> <TD> Office </ TD> <TD> Windows </ TD> </ TD> <TD> <TD> Photoshop < / TD> <TD> Java </ TD> <TD> Illustrator </ td> <td> PageMaker </ td> </ tr> <tr> <td> Cartoon </ TD> <TD> Telephone </ TD> <TD> CHINA </ TD> <TD> USA </ TD> </ TD> <TD> <TD> Java One </ TD> <TD> JBuilder </ TD> <TD > Stuts </ td> </ tr> <tr> <td> C </ TD> <TD> Visual Studio </ TD> <T D> Office </ td> <TD> Windows </ TD> </ TD> <TD> <TD> Flash </ TD> <TD> Illustrator </ td> <td> PageMaker </ Td></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-121466.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="121466" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.050</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = '4FT8mNBesz3PqluhjUqZxwy93M7s6YL6eXXI6rxJIT1Pxr1_2BwSqRAp4af7xWosq8UfPNfrxCOPytA3OJT2_2F8oA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>